diff --git a/DataBase/版本日志/SUBQHSE_V2024-12-24-gf.sql b/DataBase/版本日志/SUBQHSE_V2024-12-24-gf.sql new file mode 100644 index 00000000..5eaa10e1 --- /dev/null +++ b/DataBase/版本日志/SUBQHSE_V2024-12-24-gf.sql @@ -0,0 +1,623 @@ +ALTER TABLE Base_Project ADD MasterSysId nvarchar(200) null +GO + +alter table HSSEData_HSSE add EnvironmentalTrainNum int null +GO +alter table Project_HSSEData_HSSE add EnvironmentalTrainNum int null +GO +alter table Meeting_CompanySafetyMeeting add UnitId nvarchar(50) null +GO +alter table Meeting_CompanySpecialMeeting add UnitId nvarchar(50) null +GO +alter table CostGoods_CostSmallDetail add Extract decimal(18,0) null +GO + +update Sys_Menu set Url='HSSE/Environmental/EnvironmentalMonitoring.aspx' where MenuId='FD4E234C-265F-4B45-A35A-C9659AF9C173' +go +create table dbo.EnvironmentalCheck +( + Id nvarchar(50) not null + constraint PK_Id + primary key, + ProjectId nvarchar(50), + Tsp float, + Temp float, + Noise float, + Humid float, + PmTwoPointFive float, + WindSpeed float, + PmTen float, + Time datetime, + CreateTime datetime +) +go + +exec sp_addextendedproperty 'MS_Description', N'', 'SCHEMA', 'dbo', 'TABLE', 'EnvironmentalCheck' +go + +exec sp_addextendedproperty 'MS_Description', 'tsp', 'SCHEMA', 'dbo', 'TABLE', 'EnvironmentalCheck', 'COLUMN', 'Tsp' +go + +exec sp_addextendedproperty 'MS_Description', N'¶', 'SCHEMA', 'dbo', 'TABLE', 'EnvironmentalCheck', 'COLUMN', 'Temp' +go + +exec sp_addextendedproperty 'MS_Description', N'', 'SCHEMA', 'dbo', 'TABLE', 'EnvironmentalCheck', 'COLUMN', 'Noise' +go + +exec sp_addextendedproperty 'MS_Description', N'ʪ', 'SCHEMA', 'dbo', 'TABLE', 'EnvironmentalCheck', 'COLUMN', 'Humid' +go + +exec sp_addextendedproperty 'MS_Description', 'PM2.5', 'SCHEMA', 'dbo', 'TABLE', 'EnvironmentalCheck', 'COLUMN', + 'PmTwoPointFive' +go + +exec sp_addextendedproperty 'MS_Description', N'', 'SCHEMA', 'dbo', 'TABLE', 'EnvironmentalCheck', 'COLUMN', + 'WindSpeed' +go + +exec sp_addextendedproperty 'MS_Description', 'pm10', 'SCHEMA', 'dbo', 'TABLE', 'EnvironmentalCheck', 'COLUMN', 'PmTen' +go + +exec sp_addextendedproperty 'MS_Description', N'ʱ', 'SCHEMA', 'dbo', 'TABLE', 'EnvironmentalCheck', 'COLUMN', + 'Time' +go + +exec sp_addextendedproperty 'MS_Description', N'ʱ', 'SCHEMA', 'dbo', 'TABLE', 'EnvironmentalCheck', 'COLUMN', + 'CreateTime' +go + +alter table QualityAudit_PersonQuality add UserId nvarchar(50) null +GO +alter table Meeting_CompanySafetyMeeting add ProjectId nvarchar(50) null +GO +alter table Base_Project add IsDelete bit null +GO + + +ALTER VIEW [dbo].[View_APP_GetToDoItems] +AS +/*Ϣͼ*/ +SELECT ProjectId,UserId,UserName,COUNT(DataId) AS Counts + FROM + (SELECT HazardRegisterId AS DataId,'ȫѲ' AS MenuName,UserId,users.UserName,register.ProjectId + FROM HSSE_Hazard_HazardRegister AS register + LEFT JOIN Sys_User AS users ON (users.UserId =register.ResponsibleMan OR register.CCManIds LIKE ('%'+users.UserId+'%')) + WHERE UserId IS NOT NULL AND register.states = '1' + UNION ALL + SELECT HazardRegisterId AS DataId,'ȫѲ' AS MenuName,UserId,users.UserName,register.ProjectId + FROM HSSE_Hazard_HazardRegister AS register + LEFT JOIN Sys_User AS users ON users.UserId = register.CheckManId + WHERE UserId IS NOT NULL AND register.states = '2' + UNION ALL + SELECT PlanId AS DataId,'ѵƻ' AS MenuName,UserId,users.UserName,p.ProjectId + FROM Training_Plan AS p + LEFT JOIN Sys_User AS users ON p.DesignerId= users.UserId + WHERE UserId IS NOT NULL AND (States = '0' OR States = '1') + UNION ALL + SELECT TestPlanId AS DataId ,'Լƻ' AS MenuName,UserId,users.UserName,TPlan.ProjectId + FROM Training_TestPlan AS TPlan + LEFT JOIN Sys_User AS users ON users.UserId =TPlan.PlanManId + WHERE UserId IS NOT NULL AND (States = '0' OR States = '1' ) + UNION ALL + SELECT FireWorkId AS DataId,'ҵ' AS MenuName,UserId,users.UserName,License.ProjectId + FROM License_FireWork AS License + LEFT JOIN Sys_User AS users ON (users.UserId =License.NextManId OR License.NextManId LIKE '%'+ users.UserId+'%') + WHERE UserId IS NOT NULL AND (States = '0' OR States = '1') + UNION ALL + SELECT HeightWorkId AS DataId,'ߴҵ' AS MenuName,UserId,users.UserName,License.ProjectId + FROM License_HeightWork AS License + LEFT JOIN Sys_User AS users ON (users.UserId =License.NextManId OR License.NextManId LIKE '%'+ users.UserId+'%') + WHERE UserId IS NOT NULL AND (States = '0' OR States = '1') + UNION ALL + SELECT LimitedSpaceId AS DataId,'޿ռ' AS MenuName,UserId,users.UserName,License.ProjectId + FROM License_LimitedSpace AS License + LEFT JOIN Sys_User AS users ON (users.UserId =License.NextManId OR License.NextManId LIKE '%'+ users.UserId+'%') + WHERE UserId IS NOT NULL AND (States = '0' OR States = '1') + UNION ALL + SELECT RadialWorkId AS DataId,'ҵ' AS MenuName,UserId,users.UserName,License.ProjectId + FROM License_RadialWork AS License + LEFT JOIN Sys_User AS users ON (users.UserId =License.NextManId OR License.NextManId LIKE '%'+ users.UserId+'%') + WHERE UserId IS NOT NULL AND (States = '0' OR States = '1') + UNION ALL + SELECT OpenCircuitId AS DataId,'·(ռ)' AS MenuName,UserId,users.UserName,License.ProjectId + FROM License_OpenCircuit AS License + LEFT JOIN Sys_User AS users ON (users.UserId =License.NextManId OR License.NextManId LIKE '%'+ users.UserId+'%') + WHERE UserId IS NOT NULL AND (States = '0' OR States = '1') + UNION ALL + SELECT BreakGroundId AS DataId,'ҵ' AS MenuName,UserId,users.UserName,License.ProjectId + FROM License_BreakGround AS License + LEFT JOIN Sys_User AS users ON (users.UserId =License.NextManId OR License.NextManId LIKE '%'+ users.UserId+'%') + WHERE UserId IS NOT NULL AND (States = '0' OR States = '1') + UNION ALL + SELECT NightWorkId AS DataId,'ҹʩ' AS MenuName,UserId,users.UserName,License.ProjectId + FROM License_NightWork AS License + LEFT JOIN Sys_User AS users ON (users.UserId =License.NextManId OR License.NextManId LIKE '%'+ users.UserId+'%') + WHERE UserId IS NOT NULL AND (States = '0' OR States = '1') + UNION ALL + SELECT LiftingWorkId AS DataId,'װҵ' AS MenuName,UserId,users.UserName,License.ProjectId + FROM License_LiftingWork AS License + LEFT JOIN Sys_User AS users ON (users.UserId =License.NextManId OR License.NextManId LIKE '%'+ users.UserId+'%') + WHERE UserId IS NOT NULL AND (States = '0' OR States = '1') + UNION ALL + SELECT PersonId AS DataId,'ֳԱ' AS MenuName,UserId,users.UserName,Person.ProjectId + FROM SitePerson_Person AS Person + LEFT JOIN Sys_User AS users ON Person.AuditorId =users.UserId + WHERE UserId IS NOT NULL AND Person.AuditorDate IS NULL AND (Person.IsUsed IS NULL OR Person.IsUsed= 0) + UNION ALL + SELECT PersonQualityId AS DataId,'ҵԱ' AS MenuName,users.UserId,users.UserName,Person.ProjectId + FROM QualityAudit_PersonQuality AS p + LEFT JOIN SitePerson_Person AS Person ON Person.PersonId =p.PersonId + LEFT JOIN Sys_User AS users ON users.UserId =p.AuditorId + WHERE users.UserId IS NOT NULL AND p.States ='1' + UNION ALL + SELECT SafePersonQualityId AS DataId,'Ա' AS MenuName,users.UserId,users.UserName,Person.ProjectId + FROM QualityAudit_SafePersonQuality AS p + LEFT JOIN SitePerson_Person AS Person ON Person.PersonId =p.PersonId + LEFT JOIN Sys_User AS users ON users.UserId =p.AuditorId + WHERE UserId IS NOT NULL AND p.States ='1' + UNION ALL + SELECT EquipmentPersonQualityId AS DataId,'豸ҵԱ' AS MenuName,users.UserId,users.UserName,Person.ProjectId + FROM QualityAudit_EquipmentPersonQuality AS p + LEFT JOIN SitePerson_Person AS Person ON Person.PersonId =p.PersonId + LEFT JOIN Sys_User AS users ON users.UserId =p.AuditorId + WHERE UserId IS NOT NULL AND p.States ='1' + UNION ALL + SELECT TaskId AS DataId,'ѵ' AS MenuName,users.UserId,users.UserName,Task.ProjectId + FROM Training_Task AS Task + LEFT JOIN Sys_User AS users ON users.UserId =Task.UserId + WHERE users.UserId IS NOT NULL AND (Task.States IS NULL OR Task.States != 2) +UNION ALL + SELECT RectifyNoticesId AS DataId,'' AS MenuName,users.UserId,users.UserName,Rectify.ProjectId + FROM Check_RectifyNotices AS Rectify + LEFT JOIN Sys_User AS users ON Rectify.CompleteManId = users.UserId + WHERE UserId IS NOT NULL AND ISNULL(Rectify.States,0) =0 + UNION ALL + (SELECT RectifyNoticesId AS DataId,'' AS MenuName,users.UserId,users.UserName,Rectify.ProjectId + FROM Check_RectifyNotices AS Rectify + LEFT JOIN Sys_User AS users ON Rectify.SignPerson= users.UserId + WHERE UserId IS NOT NULL AND Rectify.States =1 + UNION ALL + SELECT RectifyNoticesId AS DataId,'' AS MenuName,users.UserId,users.UserName,Rectify.ProjectId + FROM Check_RectifyNotices AS Rectify + LEFT JOIN Sys_User AS users ON Rectify.DutyPersonId= users.UserId + WHERE UserId IS NOT NULL AND Rectify.States =2 + UNION ALL + SELECT RectifyNoticesId AS DataId,'' AS MenuName,users.UserId,users.UserName,Rectify.ProjectId + FROM Check_RectifyNotices AS Rectify + LEFT JOIN Sys_User AS users ON Rectify.UnitHeadManId =users.UserId + WHERE UserId IS NOT NULL AND Rectify.States =3 + UNION ALL + SELECT RectifyNoticesId AS DataId,'' AS MenuName,users.UserId,users.UserName,Rectify.ProjectId + FROM Check_RectifyNotices AS Rectify + LEFT JOIN Sys_User AS users ON Rectify.CheckPerson =users.UserId + WHERE UserId IS NOT NULL AND Rectify.States =4 + UNION ALL + SELECT RectifyNoticesId AS DataId,'' AS MenuName,users.UserId,users.UserName,Rectify.ProjectId + FROM Check_RectifyNotices AS Rectify + LEFT JOIN Sys_User AS users ON Rectify.ProfessionalEngineerId =users.UserId + WHERE UserId IS NOT NULL AND Rectify.States <> 5 AND (ProfessionalEngineerTime1 IS NULL OR ProfessionalEngineerTime2 IS NULL) + UNION ALL + SELECT RectifyNoticesId AS DataId,'' AS MenuName,users.UserId,users.UserName,Rectify.ProjectId + FROM Check_RectifyNotices AS Rectify + LEFT JOIN Sys_User AS users ON Rectify.ConstructionManagerId =users.UserId + WHERE UserId IS NOT NULL AND Rectify.States <> 5 AND (ConstructionManagerTime1 IS NULL OR ConstructionManagerTime2 IS NULL) + UNION ALL + SELECT RectifyNoticesId AS DataId,'' AS MenuName,users.UserId,users.UserName,Rectify.ProjectId + FROM Check_RectifyNotices AS Rectify + LEFT JOIN Sys_User AS users ON Rectify.ProjectManagerId =users.UserId + WHERE UserId IS NOT NULL AND Rectify.States <> 5 AND (ProjectManagerTime1 IS NULL OR ProjectManagerTime2 IS NULL)) +--UNION ALL +-- (SELECT PunishNoticeId AS DataId,'' AS MenuName,users.UserId,users.UserName,PunishNotice.ProjectId +-- FROM Check_PunishNotice AS PunishNotice +-- LEFT JOIN Sys_User AS users ON PunishNotice.CompileMan = users.UserId +-- WHERE UserId IS NOT NULL AND ISNULL(PunishNotice.PunishStates,0) =0 +-- UNION ALL +-- SELECT PunishNoticeId AS DataId,'' AS MenuName,users.UserId,users.UserName,PunishNotice.ProjectId +-- FROM Check_PunishNotice AS PunishNotice +-- LEFT JOIN Sys_User AS users ON PunishNotice.SignMan= users.UserId +-- WHERE UserId IS NOT NULL AND PunishNotice.PunishStates =1 +-- UNION ALL +-- SELECT PunishNoticeId AS DataId,'' AS MenuName,users.UserId,users.UserName,PunishNotice.ProjectId +-- FROM Check_PunishNotice AS PunishNotice +-- LEFT JOIN Sys_User AS users ON PunishNotice.ApproveMan= users.UserId +-- WHERE UserId IS NOT NULL AND PunishNotice.PunishStates =2 +-- UNION ALL +-- SELECT PunishNoticeId AS DataId,'' AS MenuName,users.UserId,users.UserName,PunishNotice.ProjectId +-- FROM Check_PunishNotice AS PunishNotice +-- LEFT JOIN Sys_User AS users ON PunishNotice.DutyPersonId =users.UserId +-- WHERE UserId IS NOT NULL AND PunishNotice.PunishStates =3 +-- UNION ALL +-- SELECT PunishNoticeId AS DataId,'' AS MenuName,users.UserId,users.UserName,PunishNotice.ProjectId +-- FROM Check_PunishNotice AS PunishNotice +-- LEFT JOIN Sys_User AS users ON PunishNotice.ProfessionalEngineerId =users.UserId +-- WHERE UserId IS NOT NULL AND PunishNotice.PunishStates <> 4 AND ProfessionalEngineerTime IS NULL +-- UNION ALL +-- SELECT PunishNoticeId AS DataId,'' AS MenuName,users.UserId,users.UserName,PunishNotice.ProjectId +-- FROM Check_PunishNotice AS PunishNotice +-- LEFT JOIN Sys_User AS users ON PunishNotice.ConstructionManagerId =users.UserId +-- WHERE UserId IS NOT NULL AND PunishNotice.PunishStates <> 4 AND ConstructionManagerTime IS NULL +-- UNION ALL +-- SELECT PunishNoticeId AS DataId,'' AS MenuName,users.UserId,users.UserName,PunishNotice.ProjectId +-- FROM Check_PunishNotice AS PunishNotice +-- LEFT JOIN Sys_User AS users ON PunishNotice.UnitHeadManId =users.UserId +-- WHERE UserId IS NOT NULL AND PunishNotice.PunishStates <> 4 AND UnitHeadManTime IS NULL) +UNION ALL + (SELECT PauseNoticeId AS DataId,'ͣ' AS MenuName,users.UserId,users.UserName,PauseNotice.ProjectId + FROM Check_PauseNotice AS PauseNotice + LEFT JOIN Sys_User AS users ON PauseNotice.CompileManId = users.UserId + WHERE UserId IS NOT NULL AND ISNULL(PauseNotice.PauseStates,0) =0 + UNION ALL + SELECT PauseNoticeId AS DataId,'ͣ' AS MenuName,users.UserId,users.UserName,PauseNotice.ProjectId + FROM Check_PauseNotice AS PauseNotice + LEFT JOIN Sys_User AS users ON PauseNotice.SignManId= users.UserId + WHERE UserId IS NOT NULL AND PauseNotice.PauseStates =1 + UNION ALL + SELECT PauseNoticeId AS DataId,'ͣ' AS MenuName,users.UserId,users.UserName,PauseNotice.ProjectId + FROM Check_PauseNotice AS PauseNotice + LEFT JOIN Sys_User AS users ON PauseNotice.ApproveManId= users.UserId + WHERE UserId IS NOT NULL AND PauseNotice.PauseStates =2 + UNION ALL + SELECT PauseNoticeId AS DataId,'ͣ' AS MenuName,users.UserId,users.UserName,PauseNotice.ProjectId + FROM Check_PauseNotice AS PauseNotice + LEFT JOIN Sys_User AS users ON PauseNotice.DutyPersonId =users.UserId + WHERE UserId IS NOT NULL AND PauseNotice.PauseStates =3 + UNION ALL + SELECT PauseNoticeId AS DataId,'ͣ' AS MenuName,users.UserId,users.UserName,PauseNotice.ProjectId + FROM Check_PauseNotice AS PauseNotice + LEFT JOIN Sys_User AS users ON PauseNotice.ProfessionalEngineerId =users.UserId + WHERE UserId IS NOT NULL AND PauseNotice.PauseStates <> 4 AND ProfessionalEngineerTime IS NULL + UNION ALL + SELECT PauseNoticeId AS DataId,'ͣ' AS MenuName,users.UserId,users.UserName,PauseNotice.ProjectId + FROM Check_PauseNotice AS PauseNotice + LEFT JOIN Sys_User AS users ON PauseNotice.ConstructionManagerId =users.UserId + WHERE UserId IS NOT NULL AND PauseNotice.PauseStates <> 4 AND ConstructionManagerTime IS NULL + UNION ALL + SELECT PauseNoticeId AS DataId,'ͣ' AS MenuName,users.UserId,users.UserName,PauseNotice.ProjectId + FROM Check_PauseNotice AS PauseNotice + LEFT JOIN Sys_User AS users ON PauseNotice.UnitHeadManId =users.UserId + WHERE UserId IS NOT NULL AND PauseNotice.PauseStates <> 4 AND UnitHeadManTime IS NULL + UNION ALL + SELECT PauseNoticeId AS DataId,'ͣ' AS MenuName,users.UserId,users.UserName,PauseNotice.ProjectId + FROM Check_PauseNotice AS PauseNotice + LEFT JOIN Sys_User AS users ON PauseNotice.SupervisorManId =users.UserId + WHERE UserId IS NOT NULL AND PauseNotice.PauseStates <> 4 AND SupervisorManTime IS NULL + UNION ALL + SELECT PauseNoticeId AS DataId,'ͣ' AS MenuName,users.UserId,users.UserName,PauseNotice.ProjectId + FROM Check_PauseNotice AS PauseNotice + LEFT JOIN Sys_User AS users ON PauseNotice.OwnerId =users.UserId + WHERE UserId IS NOT NULL AND PauseNotice.PauseStates <> 4 AND OwnerTime IS NULL) +) AS V + +GROUP BY ProjectId,UserId,UserName + + +GO + + +alter table EnvironmentalCheck add IsPushed bit null +GO + + +--ȡǰ˴ +ALTER PROCEDURE [dbo].[Sp_Project_GetToDoItems] + @projectId NVARCHAR(50)=NULL, + @userId NVARCHAR(200)=NULL +AS +/*ȡǰ˴*/ +BEGIN +SELECT HazardRegisterId AS DataId + ,'B6BE5FE0-CB84-47FF-A6C3-5AD9E1CCE079' AS MenuId + ,'ȫѲ' AS MenuName + ,register.RegisterDef AS Content + ,UserId + ,users.UserName + ,register.RegisterDate AS DataTime + ,CONVERT(varchar(100),register.RegisterDate, 23) AS DataTimeStr + ,'../HSSE/HiddenInspection/HiddenRectificationRectify.aspx?HazardRegisterId='+register.HazardRegisterId AS PCUrl +FROM HSSE_Hazard_HazardRegister AS register +LEFT JOIN Sys_User AS users ON users.UserId =@userId +WHERE register.ProjectId=@projectId AND +((register.states = '1' AND (register.ResponsibleMan =@userId OR register.CCManIds LIKE ('%'+@userId+'%') )) +) +UNION ALL + +SELECT HazardRegisterId AS DataId + ,'B6BE5FE0-CB84-47FF-A6C3-5AD9E1CCE079' AS MenuId + ,'ȫѲȷ' AS MenuName + ,register.RegisterDef AS Content + ,UserId + ,users.UserName + ,register.RegisterDate AS DataTime + ,CONVERT(varchar(100),register.RegisterDate, 23) AS DataTimeStr + ,'../HSSE/HiddenInspection/HiddenRectificationConfirm.aspx?HazardRegisterId='+register.HazardRegisterId AS PCUrl +FROM HSSE_Hazard_HazardRegister AS register +LEFT JOIN Sys_User AS users ON users.UserId =@userId +WHERE register.ProjectId=@projectId AND +register.states = '2' AND register.CheckManId =@userId + +UNION ALL +SELECT CheckControlCode AS DataId + ,'B3E99BD9-FDC7-4F15-8C3C-A7821AC9E306' AS MenuId + ,'Ѳ' AS MenuName + ,checkControl.QuestionDef AS Content + ,UserId + ,users.UserName + ,checkControl.CheckDate AS DataTime + ,CONVERT(varchar(100),checkControl.CheckDate, 23) AS DataTimeStr + ,'../CQMS/Check/ChecklistEdit.aspx?ToDo=ToDo&CheckControlCode='+checkControl.CheckControlCode AS PCUrl +FROM Check_CheckControl AS checkControl +LEFT JOIN Sys_User AS users ON users.UserId =@userId +WHERE checkControl.ProjectId=@projectId AND +checkControl.State != '7' AND checkControl.CheckControlCode in (select CheckControlCode from Check_CheckControlApprove approve where approve.ApproveType!='S' and approve.ApproveMan=@userId and approve.ApproveDate is null ) + +UNION ALL +SELECT GJSXID AS DataId + ,'0BEA2126-7A48-40EB-8E21-99148E91A22B' AS MenuId + ,'ؼ' AS MenuName + ,GJSX.Detail AS Content + ,users.UserId + ,users.UserName + ,GJSX.CreateDate AS DataTime + ,CONVERT(varchar(100),GJSX.CreateDate, 23) AS DataTimeStr + ,'../PZHGL/GJSX/GJSXListEdit.aspx?ToDo=ToDo&EditType=Edit&ID='+GJSXID AS PCUrl +FROM GJSX +LEFT JOIN Sys_User AS users ON users.UserId =@userId +WHERE GJSX.ProjectId=@projectId AND +GJSX.State != 0 AND (((select count(*) from GJSX_detail detail where detail.Progress_user=@userId and detail.GJSXID=GJSX.GJSXID)=0 +and (select count(*) from GJSX_Process process where process.UserId=@userId and process.GJSXID=GJSX.GJSXID)>0) +or (GJSX.User_Acceptance like '%'+@userId+'%' and (select count(*) from GJSX_detail detail where detail.GJSXID=GJSX.GJSXID)=(select count(*) from GJSX_Process process where process.GJSXID=GJSX.GJSXID)) +) + +--UNION ALL +--SELECT InspectionEquipmentId AS DataId +-- ,'6c2c1e5e-1812-4e1c-a683-7125518e28c7' AS MenuId +-- ,'豸ϱȷ' AS MenuName +-- ,Equipment.InspectionName AS Content +-- ,UserId +-- ,users.UserName +-- ,Equipment.InspectionDate AS DataTime +-- ,CONVERT(varchar(100),Equipment.InspectionDate, 23) AS DataTimeStr +-- ,'../CQMS/Comprehensive/InspectionEquipmentEdit.aspx?ToDo=ToDo&InspectionEquipmentId='+Equipment.InspectionEquipmentId AS PCUrl +--FROM Comprehensive_InspectionEquipment AS Equipment +--LEFT JOIN Sys_User AS users ON users.UserId =@userId +--WHERE Equipment.ProjectId=@projectId and +--Equipment.Status!='3' AND Equipment.InspectionEquipmentId in (select InspectionEquipmentId from Comprehensive_InspectionEquipmentApprove approve where approve.ApproveType!='S' and approve.ApproveMan=@userId and approve.ApproveDate is null ) +--UNION ALL +--SELECT InspectionPersonId AS DataId +-- ,'8ed133de-5899-4687-878a-20b1f5280f18' AS MenuId +-- ,'Աȷ' AS MenuName +-- ,Person.PersonName AS Content +-- ,UserId +-- ,users.UserName +-- ,Person.CompileDate AS DataTime +-- ,CONVERT(varchar(100),Person.CompileDate, 23) AS DataTimeStr +-- ,'../CQMS/Comprehensive/InspectionPersonEdit.aspx?ToDo=ToDo&InspectionPersonId='+Person.InspectionPersonId AS PCUrl +--FROM Comprehensive_InspectionPerson AS Person +--LEFT JOIN Sys_User AS users ON users.UserId =@userId +--WHERE Person.ProjectId=@projectId and +--Person.Status!='3' AND Person.InspectionPersonId in (select InspectionPersonId from Comprehensive_InspectionPersonApprove approve where approve.ApproveType!='S' and approve.ApproveMan=@userId and approve.ApproveDate is null ) +--UNION ALL +--SELECT InspectionMachineId AS DataId +-- ,'aa55fad1-6c51-43f5-8c99-3c6aaae79118' AS MenuId +-- ,'߱ȷ' AS MenuName +-- ,Machine.InspectionMachineName AS Content +-- ,UserId +-- ,users.UserName +-- ,Machine.CompileDate AS DataTime +-- ,CONVERT(varchar(100),Machine.CompileDate, 23) AS DataTimeStr +-- ,'../CQMS/Comprehensive/InspectionMachineEdit.aspx?ToDo=ToDo&InspectionMachineId='+Machine.InspectionMachineId AS PCUrl +--FROM Comprehensive_InspectionMachine AS Machine +--LEFT JOIN Sys_User AS users ON users.UserId =@userId +--WHERE Machine.ProjectId=@projectId and +--Machine.Status!='3' AND Machine.InspectionMachineId in (select InspectionMachineId from Comprehensive_InspectionMachineApprove approve where approve.ApproveType!='S' and approve.ApproveMan=@userId and approve.ApproveDate is null ) +UNION ALL +SELECT ConstructSolutionId AS DataId + ,'91C4BFDB-0A51-4992-99CC-EB4EC185593D' AS MenuId + ,'ʩ' AS MenuName + ,Solution.SolutionName AS Content + ,UserId + ,users.UserName + ,Solution.CompileDate AS DataTime + ,CONVERT(varchar(100),Solution.CompileDate, 23) AS DataTimeStr + ,'../CQMS/Solution/EditConstructSolution.aspx?ToDo=ToDo&ConstructSolutionId='+Solution.ConstructSolutionId AS PCUrl +FROM Solution_CQMSConstructSolution AS Solution +LEFT JOIN Sys_User AS users ON users.UserId =@userId +WHERE Solution.ProjectId=@projectId and +Solution.State!='3' +AND Solution.ConstructSolutionId in +(select top 1 ConstructSolutionId from ( +SELECT Solution_CQMSConstructSolutionApprove.* +FROM Solution_CQMSConstructSolutionApprove, +(SELECT MIN([order]) AS [order],ConstructSolutionId FROM Solution_CQMSConstructSolutionApprove where ApproveType!='S' and ApproveDate is null GROUP BY ConstructSolutionId )b +WHERE Solution_CQMSConstructSolutionApprove.[order] = b.[order] and Solution_CQMSConstructSolutionApprove.ConstructSolutionId = b.ConstructSolutionId + ) approve +where approve.ApproveMan=@userId ) + +UNION ALL +SELECT InspectionId AS DataId + ,'4781f467-35bf-4cf2-aaa4-7960a175eb61' AS MenuId + ,'֪ͨ' AS MenuName + ,InspectionManagement.AcceptanceSite AS Content + ,UserId + ,users.UserName + ,InspectionManagement.CompileDate AS DataTime + ,CONVERT(varchar(100),InspectionManagement.CompileDate, 23) AS DataTimeStr + ,'../CQMS/ProcessControl/InspectionNoticeEdit.aspx?View=View&InspectionId='+InspectionManagement.InspectionId AS PCUrl +FROM ProcessControl_InspectionManagement AS InspectionManagement +LEFT JOIN Sys_User AS users ON users.UserId =@userId +WHERE InspectionManagement.ProjectId=@projectId and +dateadd(day,3,InspectionManagement.CompileDate)>getdate() and InspectionManagement.AcceptanceCheckMan like '%'+@userId+'%' +UNION ALL +SELECT CheckSpecialId AS DataId + ,'1B08048F-93ED-4E84-AE65-DB7917EA2DFB' AS MenuId + ,'ר' AS MenuName + ,CheckItemSet.CheckItemName AS Content + ,UserId + ,users.UserName + ,CheckSpecial.CheckTime AS DataTime + ,CONVERT(varchar(100),CheckSpecial.CheckTime, 23) AS DataTimeStr + ,'../HSSE/Check/CheckSpecialView.aspx?CheckSpecialId='+CheckSpecial.CheckSpecialId AS PCUrl +FROM Check_CheckSpecial AS CheckSpecial +LEFT JOIN Sys_User AS users ON users.UserId =@userId +LEFT JOIN Technique_CheckItemSet AS CheckItemSet ON CheckItemSet.CheckItemSetId =CheckSpecial.CheckItemSetId +WHERE CheckSpecial.ProjectId=@projectId and +dateadd(day,3,CheckSpecial.CheckTime)>getdate() and CheckSpecial.PartInPersonIds like '%'+@userId+'%' +UNION ALL +SELECT CheckColligationId AS DataId + ,'C198EBA8-9E23-4654-92E1-09C61105C522' AS MenuId + ,'ۺϼ' AS MenuName + ,case CheckType when '0' then 'ܼ' when '1' then '¼' else '' end AS Content + ,users.UserId + ,users.UserName + ,CheckColligation.CheckTime AS DataTime + ,CONVERT(varchar(100),CheckColligation.CheckTime, 23) AS DataTimeStr + ,'../HSSE/Check/CheckColligationEdit.aspx?CheckColligationId='+CheckColligation.CheckColligationId AS PCUrl +FROM Check_CheckColligation AS CheckColligation +LEFT JOIN Sys_User AS users ON users.UserId =@userId +LEFT JOIN Sys_FlowOperate AS FlowOperate ON CheckColligation.CheckColligationId=FlowOperate.DataId +LEFT JOIN Sys_User AS OperateUser ON FlowOperate.OperaterId=OperateUser.UserId +WHERE CheckColligation.ProjectId=@projectId and FlowOperate.IsClosed <> 1 and FlowOperate.OperaterId=@userId +UNION ALL +SELECT PatrolPlanId AS DataId + ,'D256E5C8-DC76-4F4D-BABE-A253418823F4' AS MenuId + ,'Ѳ' AS MenuName + ,HazardListItem.HazardItems AS Content + ,UserId + ,users.UserName + ,PatrolPlan.LimitCheckDate AS DataTime + ,CONVERT(varchar(100),PatrolPlan.LimitCheckDate, 23) AS DataTimeStr + ,'../HSSE/Hazard/RoutingInspectionEdit.aspx?PatrolPlanId='+PatrolPlan.PatrolPlanId AS PCUrl +FROM Hazard_PatrolPlan AS PatrolPlan +LEFT JOIN Sys_User AS users ON users.UserId =@userId +LEFT JOIN Hazard_HazardSelectedItem AS HazardListItem on HazardListItem.HazardSelectedItemId=PatrolPlan.HazardSelectedItemId +WHERE HazardListItem.ProjectId=@projectId and +dateadd(day,-3,PatrolPlan.LimitCheckDate)=22 and (select COUNT(*) from JDGL_QuantityCompletion WHERE ProjectId=@projectId and DATENAME(year,GETDATE())=DATENAME(year,EndDate) and DATENAME(MONTH,GETDATE())=DATENAME(MONTH,EndDate))=0) +or (DATEADD(day,60,(select top 1 EndDate from JDGL_QuantityCompletion WHERE ProjectId=@projectId order by EndDate desc))=22 and +DATENAME(year,GETDATE())=DATENAME(year,MonthPlan.PlanDate) and DATENAME(MONTH,GETDATE())=DATENAME(MONTH,MonthPlan.PlanDate) + + +ORDER BY DataTime DESC +END + + + +GO + + diff --git a/SGGL/BLL/BLL.csproj b/SGGL/BLL/BLL.csproj index 7a73dcf4..a448f80e 100644 --- a/SGGL/BLL/BLL.csproj +++ b/SGGL/BLL/BLL.csproj @@ -10,7 +10,7 @@ Properties BLL BLL - v4.6.2 + v4.6.1 512 @@ -309,6 +309,7 @@ + @@ -815,6 +816,8 @@ + + diff --git a/SGGL/BLL/BaseInfo/PostService.cs b/SGGL/BLL/BaseInfo/PostService.cs index 417a1a3b..3ac7c552 100644 --- a/SGGL/BLL/BaseInfo/PostService.cs +++ b/SGGL/BLL/BaseInfo/PostService.cs @@ -10,128 +10,139 @@ namespace BLL /// /// 工种表 /// - public static class PostService + public static class PostService { - public static Model.SGGLDB db = Funs.DB; + public static Model.SGGLDB db = Funs.DB; - /// - /// 记录数 - /// - private static int count - { - get; - set; - } + /// + /// 记录数 + /// + private static int count + { + get; + set; + } - /// - /// 获取分页列表 - /// - /// - /// - /// - /// - public static IEnumerable GetListData(string postName, int startRowIndex, int maximumRows) - { - IQueryable q = from x in db.Base_Post orderby x.PostName select x; - if (!string.IsNullOrEmpty(postName)) - { - q = q.Where(e => e.PostName.Contains(postName)); - } - count = q.Count(); - if (count==0) - { - return new object[] { "" }; - } - return from x in q.Skip(startRowIndex).Take(maximumRows) - select new - { - x.PostId, - x.PostName, - x.Remark - }; - } + /// + /// 获取分页列表 + /// + /// + /// + /// + /// + public static IEnumerable GetListData(string postName, int startRowIndex, int maximumRows) + { + IQueryable q = from x in db.Base_Post orderby x.PostName select x; + if (!string.IsNullOrEmpty(postName)) + { + q = q.Where(e => e.PostName.Contains(postName)); + } + count = q.Count(); + if (count == 0) + { + return new object[] { "" }; + } + return from x in q.Skip(startRowIndex).Take(maximumRows) + select new + { + x.PostId, + x.PostName, + x.Remark + }; + } - /// - /// 获取分页列表数 - /// - /// - /// - public static int GetListCount(string postName) - { - return count; - } + /// + /// 获取分页列表数 + /// + /// + /// + public static int GetListCount(string postName) + { + return count; + } - /// - /// 根据主键获取岗位信息 - /// - /// - /// - public static Model.Base_Post GetPostById(string postId) - { - return Funs.DB.Base_Post.FirstOrDefault(e => e.PostId == postId); - } + /// + /// 根据主键获取岗位信息 + /// + /// + /// + public static Model.Base_Post GetPostById(string postId) + { + return Funs.DB.Base_Post.FirstOrDefault(e => e.PostId == postId); + } - /// - /// 添加工种信息 - /// - /// - public static void AddPost(Model.Base_Post post) - { - Model.SGGLDB db = Funs.DB; - Model.Base_Post newPost = new Model.Base_Post(); - newPost.PostId = post.PostId; - newPost.PostName = post.PostName; - newPost.Remark = post.Remark; - db.Base_Post.InsertOnSubmit(newPost); - db.SubmitChanges(); - } + public static string GetPostNameById(string postId) + { + string name = string.Empty; + var q = Funs.DB.Base_Post.FirstOrDefault(e => e.PostId == postId); + if (q != null) + { + name = q.PostName; + } + return name; + } - /// - /// 修改工种信息 - /// - /// - public static void UpdatePost(Model.Base_Post post) - { - Model.SGGLDB db = Funs.DB; - Model.Base_Post newPost = db.Base_Post.FirstOrDefault(e => e.PostId == post.PostId); - if (newPost != null) - { - newPost.PostName = post.PostName; - newPost.Remark = post.Remark; - db.SubmitChanges(); - } - } + /// + /// 添加工种信息 + /// + /// + public static void AddPost(Model.Base_Post post) + { + Model.SGGLDB db = Funs.DB; + Model.Base_Post newPost = new Model.Base_Post(); + newPost.PostId = post.PostId; + newPost.PostName = post.PostName; + newPost.Remark = post.Remark; + db.Base_Post.InsertOnSubmit(newPost); + db.SubmitChanges(); + } - /// - /// 根据主键删除工种信息 - /// - /// - public static void DeletePost(string postId) - { - Model.SGGLDB db = Funs.DB; - Model.Base_Post newPost = db.Base_Post.FirstOrDefault(e => e.PostId == postId); - if (newPost != null) - { - db.Base_Post.DeleteOnSubmit(newPost); - db.SubmitChanges(); - } - } + /// + /// 修改工种信息 + /// + /// + public static void UpdatePost(Model.Base_Post post) + { + Model.SGGLDB db = Funs.DB; + Model.Base_Post newPost = db.Base_Post.FirstOrDefault(e => e.PostId == post.PostId); + if (newPost != null) + { + newPost.PostName = post.PostName; + newPost.Remark = post.Remark; + db.SubmitChanges(); + } + } - /// - /// 获取工种名称项 - /// - /// - /// - public static ListItem[] drpPostNameItemList() - { - var q = (from x in Funs.DB.Base_Post orderby x.PostName select x).ToList(); - ListItem[] list = new ListItem[q.Count()]; - for (int i = 0; i < list.Count(); i++) - { - list[i] = new ListItem(q[i].PostName ?? "", q[i].PostId); - } - return list; - } + /// + /// 根据主键删除工种信息 + /// + /// + public static void DeletePost(string postId) + { + Model.SGGLDB db = Funs.DB; + Model.Base_Post newPost = db.Base_Post.FirstOrDefault(e => e.PostId == postId); + if (newPost != null) + { + db.Base_Post.DeleteOnSubmit(newPost); + db.SubmitChanges(); + } + } + + /// + /// 获取工种名称项 + /// + /// + /// + public static ListItem[] drpPostNameItemList() + { + var q = (from x in Funs.DB.Base_Post orderby x.PostName select x).ToList(); + ListItem[] list = new ListItem[q.Count()]; + for (int i = 0; i < list.Count(); i++) + { + list[i] = new ListItem(q[i].PostName ?? "", q[i].PostId); + } + return list; + } public static void InitPostDownList(FineUIPro.DropDownList dropName, bool isShowPlease) { diff --git a/SGGL/BLL/Common/CommonService.cs b/SGGL/BLL/Common/CommonService.cs index ddc01eb5..44baee67 100644 --- a/SGGL/BLL/Common/CommonService.cs +++ b/SGGL/BLL/Common/CommonService.cs @@ -624,5 +624,31 @@ namespace BLL { return (Funs.DB.Base_Unit.FirstOrDefault(e => e.UnitId == Const.UnitId_CWCEC)); //本单位 } + + /// + ///根据userid获取当前人的单位类型(0总公司,1分公司,2其他) + /// + /// + /// + public static int GetUnitTypeByUserId(string userId) + { + int result = 0; + var user = UserService.GetUserByUserId(userId); + + + if ((userId == Const.hfnbdId || userId == Const.sysglyId) || (!string.IsNullOrEmpty(user.UnitId) && user.UnitId == CommonService.GetThisUnitId()))//公司级别 + { + result = 0; + } + else if (!string.IsNullOrEmpty(user.UnitId) && UnitService.GetUnitByUnitId(user.UnitId).IsBranch == true && user.IsOffice == true) //子公司级数据 + { + result = 1; + } + else //外来账户 + { + result = 2; + } + return result; + } } } diff --git a/SGGL/BLL/Common/Funs.cs b/SGGL/BLL/Common/Funs.cs index 4df1e5b8..8721a6eb 100644 --- a/SGGL/BLL/Common/Funs.cs +++ b/SGGL/BLL/Common/Funs.cs @@ -1302,6 +1302,27 @@ namespace BLL } + private static string _SGGLApiUrl; + + public static string SGGLApiUrl + { + get + { + var sysSet = (from x in DB.Sys_Set where x.SetName == "ӿڷʵַ" select x).ToList().FirstOrDefault(); + if (sysSet != null) + { + _SGGLApiUrl = sysSet.SetValue; + } + else + { + _SGGLApiUrl = ""; + } + + return _SGGLApiUrl; + } + set { _SGGLApiUrl = value; } + } + } } diff --git a/SGGL/BLL/EnvironmentalCheckService.cs b/SGGL/BLL/EnvironmentalCheckService.cs new file mode 100644 index 00000000..bbfdfc2c --- /dev/null +++ b/SGGL/BLL/EnvironmentalCheckService.cs @@ -0,0 +1,57 @@ +using Model; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace BLL +{ + /// + /// 环境监测数据 + /// + public static class EnvironmentalCheckService + { + public static Model.SGGLDB db = Funs.DB; + + #region 推送环境监测数据 + + /// + /// 推送环境监测数据 + /// + /// + public static ReturnData PushEnvironmentalCheckData() + { + var items = (from x in db.EnvironmentalCheck where x.IsPushed == false select x).ToList(); + Model.ReturnData responeData = new Model.ReturnData(); + if (items.Count() > 0) + { + var thisUnit = CommonService.GetIsThisUnit(); + var newItem = new { CollCropCode = thisUnit.CollCropCode, Items = items }; + var str = JsonConvert.SerializeObject(newItem); + var baseurl = "/api/Environmental/SaveEnvironmentalCheckData"; + responeData = ServerService.PushCNCEC(str, baseurl); + if (responeData.code == 1) + {//推送成功后,修改数据状态 + foreach (var item in items) + { + Model.EnvironmentalCheck envModel = db.EnvironmentalCheck.FirstOrDefault(e => e.Id == item.Id); + if (envModel != null) + { + envModel.IsPushed = true; + db.SubmitChanges(); + } + } + } + } + else + { + responeData.code = 0; + responeData.message = "当前没有环境监测数据"; + } + return responeData; + } + + #endregion + } +} diff --git a/SGGL/BLL/ProjectData/ProjectService.cs b/SGGL/BLL/ProjectData/ProjectService.cs index fcf65cef..bc3b852b 100644 --- a/SGGL/BLL/ProjectData/ProjectService.cs +++ b/SGGL/BLL/ProjectData/ProjectService.cs @@ -4,6 +4,7 @@ using System.Linq; using Model; using System; + using Newtonsoft.Json; public static class ProjectService { @@ -724,5 +725,59 @@ } #endregion + + /// + /// 获取主数据项目 + /// + /// + public static List GetMasterProjectInfos() + { + var thisUnit = CommonService.GetIsThisUnit(); + Dictionary dic = new Dictionary() + { + {"collCropCode", thisUnit.CollCropCode} + }; + List projectlist = new List(); + var returnData = ServerService.GerDataFromCncec("api/Common/GetMasterDataProjectByCollCropCode", dic, null); + if (returnData != null && returnData.code == 1) + { + projectlist = JsonConvert.DeserializeObject>(returnData.data.ToString()); + } + + return projectlist; + } + + /// + /// 获取主数据项目(下拉框) + /// + /// + /// + public static void InitMasterProjectDropDownList(FineUIPro.DropDownList dropName, bool isShowPlease) + { + dropName.DataValueField = "SysId"; + dropName.DataTextField = "PrjName"; + var thisUnit = CommonService.GetIsThisUnit(); + Dictionary dic = new Dictionary() + { + {"collCropCode", thisUnit.CollCropCode} + }; + List projectlist = new List(); + var returnData = ServerService.GerDataFromCncec("api/Common/GetMasterDataProjectByCollCropCode", dic, null); + if (returnData != null && returnData.code == 1) + { + projectlist = JsonConvert.DeserializeObject>(returnData.data.ToString()); + } + + dropName.DataSource = projectlist; + dropName.DataBind(); + if (projectlist.Count() == 0) + { + isShowPlease = true; + } + if (isShowPlease) + { + Funs.FineUIPleaseSelect(dropName); + } + } } } \ No newline at end of file diff --git a/SGGL/BLL/WebService/CNCECHSSEWebService.cs b/SGGL/BLL/WebService/CNCECHSSEWebService.cs index ee7bcc3d..c90d4d8b 100644 --- a/SGGL/BLL/WebService/CNCECHSSEWebService.cs +++ b/SGGL/BLL/WebService/CNCECHSSEWebService.cs @@ -3517,6 +3517,93 @@ return responeData.code; } #endregion + + #region 项目推送 + /// + /// 推送项目到集团 + /// + /// + public static string PushProject() + { + string code = "0"; + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) + { + try + { + //查询所有在建项目 + var upReport = (from x in db.Base_Project + where (x.ProjectState == "1" || x.ProjectState == null) + select new Model.BaseProjectItem + { + ProjectId = x.ProjectId, + MasterSysId = x.MasterSysId, + UnitId = CommonService.GetThisUnitId(), + ProjectCode = x.ProjectCode, + ProjectName = x.ProjectName, + StartDate = x.StartDate, + EndDate = x.EndDate, + ProjectAddress = x.ProjectAddress, + ShortName = x.ShortName, + ProjectType = x.ProjectType, + PostCode = x.PostCode, + Remark = x.Remark, + ProjectState = x.ProjectState, + ContractNo = x.ContractNo, + WorkRange = x.WorkRange, + Duration = x.Duration, + IsUpTotalMonth = x.IsUpTotalMonth, + ProjectMainPerson = x.ProjectMainPerson, + ProjectLiaisonPerson = x.ProjectLiaisonPerson, + IsForeign = x.IsForeign, + FromProjectId = x.FromProjectId, + MapCoordinates = x.MapCoordinates, + ProjectMoney = x.ProjectMoney, + ConstructionMoney = x.ConstructionMoney, + Country = x.Country, + Province = x.Province, + City = x.City, + Telephone = x.Telephone, + EnglishRemark = x.EnglishRemark, + IsFace = x.IsFace, + ProjectState2 = x.ProjectState2, + Progress = x.Progress, + MonitorPW = x.MonitorPW, + MonitorId = x.MonitorId, + ProjectAttribute = x.ProjectAttribute, + SourceUnitId = CommonService.GetThisUnitId(), + } + ); + + code = PushApiProject(upReport).ToString(); + if (code == "1") + { + + } + } + catch (Exception ex) + { + ErrLogInfo.WriteLog("【在建项目】上传到服务器", ex); + } + return code; + } + } + + + /// + /// 推送项目 + /// + /// + /// + + private static int PushApiProject(IQueryable upReport) + { + string baseurl = "/api/InspectionBrigade/SaveBaseProjectData"; + var resultJsonReport = JsonConvert.SerializeObject(upReport); + resultJsonReport = "{\"BaseProjectItems\":" + resultJsonReport.Replace("}{", ",") + "}"; + var responeData = BLL.ServerService.PushCNCEC(resultJsonReport, baseurl); + return responeData.code; + } + #endregion } diff --git a/SGGL/BLL/ZHGL/DataSync/CQMSDataService.cs b/SGGL/BLL/ZHGL/DataSync/CQMSDataService.cs index 6a49cea8..9377ca37 100644 --- a/SGGL/BLL/ZHGL/DataSync/CQMSDataService.cs +++ b/SGGL/BLL/ZHGL/DataSync/CQMSDataService.cs @@ -1,4 +1,5 @@ -using FineUIPro; +using BLL.CNCECHSSEService; +using FineUIPro; using Model; using Newtonsoft.Json; using NPOI.POIFS.Crypt.Dsig; @@ -95,59 +96,111 @@ namespace BLL public static void AddCQMSData_CQMS(CQMSData_CQMS newtable) { - var db = Funs.DB; - var table = new CQMSData_CQMS + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { - 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, - State = newtable.State, - CreateDate = newtable.CreateDate, - CreateMan = newtable.CreateMan - }; - db.CQMSData_CQMS.InsertOnSubmit(table); - db.SubmitChanges(); + 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, + 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.State = newtable.State; + table.CreateMan = newtable.CreateMan; + table.CreateDate = newtable.CreateDate; + db.SubmitChanges(); + } + } + } public static void DeleteCQMSData_CQMSById(string id) { - var db = Funs.DB; - var table = db.CQMSData_CQMS.FirstOrDefault(x => x.Id == id); - if (table != null) + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { - db.CQMSData_CQMS.DeleteOnSubmit(table); - db.SubmitChanges(); + var table = db.CQMSData_CQMS.FirstOrDefault(x => x.Id == id); + if (table != null) + { + db.CQMSData_CQMS.DeleteOnSubmit(table); + db.SubmitChanges(); + } } } @@ -236,7 +289,59 @@ namespace BLL 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(); @@ -396,52 +501,6 @@ namespace BLL return data; } - public static void UpdateCQMSData_CQMS(CQMSData_CQMS newtable) - { - var db = Funs.DB; - 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.State = newtable.State; - table.CreateMan = newtable.CreateMan; - table.CreateDate = newtable.CreateDate; - db.SubmitChanges(); - } - } /// /// 获取企业总部人数 diff --git a/SGGL/BLL/ZHGL/DataSync/HJGLData_DefectService.cs b/SGGL/BLL/ZHGL/DataSync/HJGLData_DefectService.cs index 1ab237ad..f3eecb3a 100644 --- a/SGGL/BLL/ZHGL/DataSync/HJGLData_DefectService.cs +++ b/SGGL/BLL/ZHGL/DataSync/HJGLData_DefectService.cs @@ -81,60 +81,65 @@ namespace BLL public static void AddHJGLData_Defect(Model.HJGLData_Defect newtable) { - - Model.HJGLData_Defect table = new Model.HJGLData_Defect + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { - Id = newtable.Id, - UnitId = newtable.UnitId, - CollCropCode = newtable.CollCropCode, - UnitName = newtable.UnitName, - ReportDate = newtable.ReportDate, - DefectName = newtable.DefectName, - DefectNum = newtable.DefectNum, - }; - db.HJGLData_Defect.InsertOnSubmit(table); - db.SubmitChanges(); + Model.HJGLData_Defect table = new Model.HJGLData_Defect + { + Id = newtable.Id, + UnitId = newtable.UnitId, + CollCropCode = newtable.CollCropCode, + UnitName = newtable.UnitName, + ReportDate = newtable.ReportDate, + DefectName = newtable.DefectName, + DefectNum = newtable.DefectNum, + }; + db.HJGLData_Defect.InsertOnSubmit(table); + db.SubmitChanges(); + } } public static void UpdateHJGLData_Defect(Model.HJGLData_Defect newtable) { - - Model.HJGLData_Defect table = db.HJGLData_Defect.FirstOrDefault(x => x.Id == newtable.Id); - if (table != null) + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { - table.Id = newtable.Id; - table.UnitId = newtable.UnitId; - table.CollCropCode = newtable.CollCropCode; - table.UnitName = newtable.UnitName; - table.ReportDate = newtable.ReportDate; - table.DefectName = newtable.DefectName; - table.DefectNum = newtable.DefectNum; - db.SubmitChanges(); + Model.HJGLData_Defect table = db.HJGLData_Defect.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.DefectName = newtable.DefectName; + table.DefectNum = newtable.DefectNum; + db.SubmitChanges(); + } } - } public static void DeleteHJGLData_DefectById(string Id) { - - Model.HJGLData_Defect table = db.HJGLData_Defect.FirstOrDefault(x => x.Id == Id); - if (table != null) + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { - db.HJGLData_Defect.DeleteOnSubmit(table); - db.SubmitChanges(); + Model.HJGLData_Defect table = db.HJGLData_Defect.FirstOrDefault(x => x.Id == Id); + if (table != null) + { + db.HJGLData_Defect.DeleteOnSubmit(table); + db.SubmitChanges(); + } } - } public static void DeleteHJGLData_DefectByDate(DateTime? reportDate) { - - var table = db.HJGLData_Defect.Where(x => x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0); - if (table != null) + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { - db.HJGLData_Defect.DeleteAllOnSubmit(table); - db.SubmitChanges(); - } - + var table = db.HJGLData_Defect.Where(x => x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0); + if (table != null) + { + db.HJGLData_Defect.DeleteAllOnSubmit(table); + db.SubmitChanges(); + } + } } } diff --git a/SGGL/BLL/ZHGL/DataSync/HJGLData_HJGLService.cs b/SGGL/BLL/ZHGL/DataSync/HJGLData_HJGLService.cs index ffd34465..40669c17 100644 --- a/SGGL/BLL/ZHGL/DataSync/HJGLData_HJGLService.cs +++ b/SGGL/BLL/ZHGL/DataSync/HJGLData_HJGLService.cs @@ -6,6 +6,7 @@ using System.Collections; using System.Collections.Generic; using System.Linq; using Newtonsoft.Json.Linq; +using System.Net.PeerToPeer; namespace BLL { @@ -70,36 +71,42 @@ namespace BLL public static void AddHJGLData_HJGL(HJGLData_HJGL newtable) { - var db = Funs.DB; - var table = new HJGLData_HJGL + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { - Id = newtable.Id, - UnitId = newtable.UnitId, - CollCropCode = newtable.CollCropCode, - UnitName = newtable.UnitName, - ReportDate = newtable.ReportDate, - WelderNum = newtable.WelderNum, - TotalDineNum = newtable.TotalDineNum, - CompleteDineNum = newtable.CompleteDineNum, - TotalFilmNum = newtable.TotalFilmNum, - OKFilmNum = newtable.OKFilmNum, - State = newtable.State, - CreateDate = newtable.CreateDate, - CreateMan = newtable.CreateMan - }; - db.HJGLData_HJGL.InsertOnSubmit(table); - db.SubmitChanges(); + var table = new HJGLData_HJGL + { + Id = newtable.Id, + UnitId = newtable.UnitId, + CollCropCode = newtable.CollCropCode, + UnitName = newtable.UnitName, + ReportDate = newtable.ReportDate, + WelderNum = newtable.WelderNum, + TotalDineNum = newtable.TotalDineNum, + CompleteDineNum = newtable.CompleteDineNum, + TotalFilmNum = newtable.TotalFilmNum, + OKFilmNum = newtable.OKFilmNum, + State = newtable.State, + CreateDate = newtable.CreateDate, + CreateMan = newtable.CreateMan + }; + db.HJGLData_HJGL.InsertOnSubmit(table); + db.SubmitChanges(); + } + } public static void DeleteHJGLData_HJGLById(string Id) { - var db = Funs.DB; - var table = db.HJGLData_HJGL.FirstOrDefault(x => x.Id == Id); - if (table != null) + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { - db.HJGLData_HJGL.DeleteOnSubmit(table); - db.SubmitChanges(); + var table = db.HJGLData_HJGL.FirstOrDefault(x => x.Id == Id); + if (table != null) + { + db.HJGLData_HJGL.DeleteOnSubmit(table); + db.SubmitChanges(); + } } + } public static HJGLData_HJGL GetHJGLData_HJGLById(string Id) @@ -150,12 +157,17 @@ namespace BLL public static HJGLData GetTodayHJGLData_HJGL() { - var q = GetTodayData(); var data = new HJGLData(); if (CommonService.GetIsThisUnit().CollCropCode== "91410200170644116B") { return GetELECLTodayHJGLData_HJGL(); } + if (CommonService.GetIsThisUnit().CollCropCode == "914200001775697881") + { + return GetCNCEC_16TodayHJGLData_HJGL(); + + } + var q = GetTodayData(); if (q != null && q.State == Const.CNCEC_State_S) data = StatisticalData(); else @@ -181,15 +193,74 @@ namespace BLL return data; } - + /// + /// 获取十六化建焊接数据 + /// + /// + public static HJGLData GetCNCEC_16TodayHJGLData_HJGL() + { + var data = new HJGLData(); + string baseurl = "https://aq.cncec16.com.cn/hjglWebApi/api/CNCECServer/PostGetHJGLData"; + string token = Const.sysglyId; + string response = Funs.RequestPost(baseurl, token, ""); + if (string.IsNullOrEmpty(response)) + { + try + { + baseurl = "http://192.168.1.8/hjglwebapi/api/CNCECServer/PostGetHJGLData"; + response = Funs.RequestPost(baseurl, token, ""); + } + catch (Exception e) + { + APICommonService.SaveSysHttpLog("GetCNCEC_16TodayHJGLData_HJGL", baseurl, e.ToString()); + + } + + } + var json = JsonConvert.DeserializeObject(response) as JObject; + if (json != null && json["code"]?.ToString() == "1") + { + var str = json["data"]?.ToString(); + if (str != null) data = JsonConvert.DeserializeObject(str); + } + APICommonService.SaveSysHttpLog("GetCNCEC_16TodayHJGLData_HJGL", baseurl, response); + return data; + } public static HJGLData_HJGL GetTodayData() { var q = (from x in Funs.DB.HJGLData_HJGL - where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date - select x).FirstOrDefault(); + where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date + select x).FirstOrDefault(); return q; } - + public static HJGLData_HJGL GetSubUnitHjglDataByDate(string Unitid, DateTime? reportdate) + { + var result = new Model.HJGLData_HJGL(); + if (reportdate == null) + { + return result; + } + var projectlist = BLL.ProjectService.GetProjectWorkList(Unitid); + var baseUnit = UnitService.GetUnitByUnitId(Unitid); + var ProjectData = (from x in Funs.DB.Project_HJGLData_HJGL + where x.ReportDate == reportdate && projectlist.Select(e => e.ProjectId).Contains(x.ProjectId) + select x).ToList(); + result = new HJGLData_HJGL + { + UnitId = Unitid, + CollCropCode = baseUnit.CollCropCode, + UnitName = baseUnit.UnitName, + ReportDate = DateTime.Now.Date, + WelderNum = ProjectData.Sum(x => x.WelderNum), + TotalDineNum = ProjectData.Sum(x => x.TotalDineNum), + CompleteDineNum = ProjectData.Sum(x => x.CompleteDineNum), + TotalFilmNum = ProjectData.Sum(x => x.TotalFilmNum), + OKFilmNum = ProjectData.Sum(x => x.OKFilmNum), + CreateMan = Const.sysglyId, + CreateDate = DateTime.Now + }; + return result; + } public static void UpdateTodyData_State() { var q = GetTodayData(); @@ -293,26 +364,29 @@ namespace BLL } public static void UpdateHJGLData_HJGL(HJGLData_HJGL newtable) - { - var db = Funs.DB; - var table = db.HJGLData_HJGL.FirstOrDefault(x => x.Id == newtable.Id); - if (table != null) + { + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { - table.Id = newtable.Id; - table.UnitId = newtable.UnitId; - table.CollCropCode = newtable.CollCropCode; - table.UnitName = newtable.UnitName; - table.ReportDate = newtable.ReportDate; - table.WelderNum = newtable.WelderNum; - table.TotalDineNum = newtable.TotalDineNum; - table.CompleteDineNum = newtable.CompleteDineNum; - table.TotalFilmNum = newtable.TotalFilmNum; - table.OKFilmNum = newtable.OKFilmNum; - table.State = newtable.State; - table.CreateMan = newtable.CreateMan; - table.CreateDate = newtable.CreateDate; - db.SubmitChanges(); - } + var table = db.HJGLData_HJGL.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.WelderNum = newtable.WelderNum; + table.TotalDineNum = newtable.TotalDineNum; + table.CompleteDineNum = newtable.CompleteDineNum; + table.TotalFilmNum = newtable.TotalFilmNum; + table.OKFilmNum = newtable.OKFilmNum; + table.State = newtable.State; + table.CreateMan = newtable.CreateMan; + table.CreateDate = newtable.CreateDate; + db.SubmitChanges(); + } + } + } } } \ No newline at end of file diff --git a/SGGL/BLL/ZHGL/DataSync/HSSEData_HSSEService.cs b/SGGL/BLL/ZHGL/DataSync/HSSEData_HSSEService.cs index d0037999..39bc094c 100644 --- a/SGGL/BLL/ZHGL/DataSync/HSSEData_HSSEService.cs +++ b/SGGL/BLL/ZHGL/DataSync/HSSEData_HSSEService.cs @@ -2,9 +2,14 @@ using System.Collections; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices.ComTypes; +using System.Runtime.Remoting.Contexts; +using System.Threading.Tasks; +using System.Web.UI.WebControls; +using Aspose.Words.Lists; using FineUIPro; using Model; -using Newtonsoft.Json; +using Newtonsoft.Json; namespace BLL { @@ -12,6 +17,8 @@ namespace BLL { 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(); + public static void AddHSSEData_HSSE(HSSEData_HSSE newtable) { using (var db = new SGGLDB(Funs.ConnString)) @@ -33,6 +40,7 @@ namespace BLL SafeTrainNum = newtable.SafeTrainNum, SpecialTrainNum = newtable.SpecialTrainNum, SpecialOperationTrainNum = newtable.SpecialOperationTrainNum, + EnvironmentalTrainNum = newtable.EnvironmentalTrainNum, TotalEnergyConsumption = newtable.TotalEnergyConsumption, IncomeComprehensiveEnergyConsumption = newtable.IncomeComprehensiveEnergyConsumption, NewWaterConsumption = newtable.NewWaterConsumption, @@ -195,6 +203,7 @@ namespace BLL item.ShutdownNum = dataHsse.ShutdownNum; item.SpecialEquipmentNum = dataHsse.SpecialEquipmentNum; item.SpecialOperationTrainNum = dataHsse.SpecialOperationTrainNum; + item.EnvironmentalTrainNum = dataHsse.EnvironmentalTrainNum; item.SpecialSeriousAccidentNum = dataHsse.SpecialSeriousAccidentNum; item.SpecialTrainNum = dataHsse.SpecialTrainNum; item.SuperCompletedNum = dataHsse.SuperCompletedNum; @@ -212,7 +221,9 @@ namespace BLL { var list = hSseDataHiddens.Select(detail => new HSSEDataHiddenDangerDetailItem { - Id = detail.Id, NeedRectifyNum = detail.NeedRectifyNum, TotalNum = detail.TotalNum, + Id = detail.Id, + NeedRectifyNum = detail.NeedRectifyNum, + TotalNum = detail.TotalNum, TypeName = detail.TypeName }).ToList(); @@ -297,6 +308,7 @@ namespace BLL item.ShutdownNum = dataHsse.ShutdownNum; item.SpecialEquipmentNum = dataHsse.SpecialEquipmentNum; item.SpecialOperationTrainNum = dataHsse.SpecialOperationTrainNum; + item.EnvironmentalTrainNum = dataHsse.EnvironmentalTrainNum; item.SpecialSeriousAccidentNum = dataHsse.SpecialSeriousAccidentNum; item.SpecialTrainNum = dataHsse.SpecialTrainNum; item.SuperCompletedNum = dataHsse.SuperCompletedNum; @@ -328,25 +340,19 @@ namespace BLL return data; } - public static HSSEData GetTodayHSSEData_HSSE() - { - HSSEData data; - var q = (from x in Funs.DB.HSSEData_HSSE - where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date - select x).FirstOrDefault(); - if (q != null && q.State == Const.CNCEC_State_S) - // data = GetItemByHSSEData_HSSE(q, Project_HSSEData_HiddenDangerDetailService.GetTodayModel()); ; - data = StatisticalData(); - else - data = StatisticalData(); + public static async Task GetTodayHSSEData_HSSE() + { + var modelTask= StatisticalDataAsync(); + var model=await modelTask; + HSSEData data = model; return data; - } - + } + public static HSSEData_HSSE GetTodayData() { var q = (from x in Funs.DB.HSSEData_HSSE - where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date - select x).FirstOrDefault(); + where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date + select x).FirstOrDefault(); return q; } @@ -364,8 +370,8 @@ namespace BLL { var result = false; var q = (from x in Funs.DB.HSSEData_HSSE - where x.ReportDate >= dateTime.Date && x.ReportDate < dateTime.Date.AddDays(1).Date - select x).ToList(); + where x.ReportDate >= dateTime.Date && x.ReportDate < dateTime.Date.AddDays(1).Date + select x).ToList(); if (q.Count > 0) result = true; return result; } @@ -378,8 +384,8 @@ namespace BLL { var result = false; var q = (from x in Funs.DB.HSSEData_HSSE - where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date - select x).ToList(); + where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date + select x).ToList(); if (q.Count > 0) result = true; return result; } @@ -393,26 +399,22 @@ namespace BLL return responeData; } - public static HSSEData StatisticalData() + public static Model.HSSEData_HSSE GetSubUnitHsseDataByDate(string Unitid, DateTime? reportdate) { - var thisUnitId = string.Empty; - var thisUnit = CommonService.GetIsThisUnit(); - if (thisUnit != null) thisUnitId = thisUnit.UnitId; - var baseUnit = UnitService.GetUnitByUnitId(thisUnitId); - Project_HSSEData_HSSEService.StatisticalAllProjectData(); - Project_HSSEData_HiddenDangerDetailService.StatisticalAllProjectData(); - - var projectData = (from x in Funs.DB.Project_HSSEData_HSSE - where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date - select x).ToList(); - var totalEnergyConsumption = ChemicalReportItemService.GetLatstTimeTotalEnergyConsumption(); - var incomeComprehensiveEnergyConsumption = - ChemicalReportItemService.GetLatstTimeIncomeComprehensiveEnergyConsumption(); - var newWaterConsumption = ChemicalReportItemService.GetLatstTimeNewWaterConsumption(); - - var table = new HSSEData_HSSE + var result = new Model.HSSEData_HSSE(); + if (reportdate == null) { - UnitId = thisUnitId, + return result; + } + + var projectlist = BLL.ProjectService.GetProjectWorkList(Unitid); + var baseUnit = UnitService.GetUnitByUnitId(Unitid); + var projectData = (from x in Funs.DB.Project_HSSEData_HSSE + where x.ReportDate == reportdate && projectlist.Select(e => e.ProjectId).Contains(x.ProjectId) + select x).ToList(); + result = new HSSEData_HSSE + { + UnitId = Unitid, CollCropCode = baseUnit.CollCropCode, UnitName = baseUnit.UnitName, ReportDate = DateTime.Now.Date, @@ -426,13 +428,13 @@ namespace BLL SafeTrainNum = projectData.Sum(x => x.SafeTrainNum), SpecialTrainNum = projectData.Sum(x => x.SpecialTrainNum), SpecialOperationTrainNum = projectData.Sum(x => x.SpecialOperationTrainNum), - TotalEnergyConsumption = totalEnergyConsumption, - IncomeComprehensiveEnergyConsumption = incomeComprehensiveEnergyConsumption, - NewWaterConsumption = newWaterConsumption, - HeadOfficeInspectorGeneralNum = GetHeadOfficeInspectorGeneralNum(), - HeadOfficeFullTimeNum = GetHeadOfficeFullTimeNum(), - BranchInspectorGeneralNum = GetBranchInspectorGeneralNum(), - BranchFullTimeNum = GetBranchFullTimeNum(), + TotalEnergyConsumption = 0, + IncomeComprehensiveEnergyConsumption = 0, + NewWaterConsumption = 0, + HeadOfficeInspectorGeneralNum = GetHeadOfficeInspectorGeneral().Count, + HeadOfficeFullTimeNum = GetHeadOfficeFullTime().Count, + BranchInspectorGeneralNum = GetBranchInspectorGeneral().Count, + BranchFullTimeNum = GetBranchFullTime().Count, ProjectInspectorGeneralNum = projectData.Sum(x => x.ProjectInspectorGeneralNum), ProjectFullTimeNum = projectData.Sum(x => x.ProjectFullTimeNum), ProjectSafetyMonitorNum = projectData.Sum(x => x.ProjectSafetyMonitorNum), @@ -440,13 +442,13 @@ namespace BLL CertificateANum = projectData.Sum(x => x.CertificateANum), CertificateBNum = projectData.Sum(x => x.CertificateBNum), CertificateCNum = projectData.Sum(x => x.CertificateCNum), - SafetyCommitteeMeetingNum = GetSafetyCommitteeMeetingNum(), + SafetyCommitteeMeetingNum = GetSafetyCommitteeMeeting().Count, EnterpriseTopicsMeetingNum = GetEnterpriseTopicsMeetingNum(), ProjectSafetyLeadingGroupMeetingNum = projectData.Sum(x => x.ProjectSafetyLeadingGroupMeetingNum), ProjectSafetyMeetingNum = projectData.Sum(x => x.ProjectSafetyMeetingNum), - CompanyLeadShiftCheckNum = GetCompanyLeadShiftCheckNum(), - CompanyComprehensiveCheckNum = GetCompanyComprehensiveCheckNum(), - CompanySpecialCheckNum = GetCompanySpecialCheckNum(), + CompanyLeadShiftCheckNum = GetCompanyLeadShiftCheck().Count, + CompanyComprehensiveCheckNum = GetCompanyComprehensiveCheck().Count, + CompanySpecialCheckNum = GetCompanySpecialCheck().Count, ProjectLeadShiftCheckNum = projectData.Sum(x => x.ProjectLeadShiftCheckNum), ProjectSpecialCheckNum = projectData.Sum(x => x.ProjectSpecialCheckNum), ProjectMajorCheckNum = projectData.Sum(x => x.ProjectMajorCheckNum), @@ -456,10 +458,10 @@ namespace BLL MajorAccidentNum = projectData.Sum(x => x.MajorAccidentNum), SeriousAccidentNum = projectData.Sum(x => x.SeriousAccidentNum), SpecialSeriousAccidentNum = projectData.Sum(x => x.SpecialSeriousAccidentNum), - CompanyComprehensivePlanNum = GetCompanyComprehensivePlanNum(), - CompanySpecialPlanNum = GetCompanySpecialPlanNum(), - CompanyOnSiteDisposalPlan = GetCompanyOnSiteDisposalPlan(), - CompanyDrillNum = GetCompanyDrillNum(), + // CompanyComprehensivePlanNum = GetCompanyComprehensivePlan(), + // CompanySpecialPlanNum = GetCompanySpecialPlan(), + // CompanyOnSiteDisposalPlan = GetCompanyOnSiteDisposalPlan(), + // CompanyDrillNum = GetCompanyDrill(), ProjectComprehensivePlanNum = projectData.Sum(x => x.ProjectComprehensivePlanNum), ProjectSpecialPlanNum = projectData.Sum(x => x.ProjectSpecialPlanNum), ProjectOnSiteDisposalPlan = projectData.Sum(x => x.ProjectOnSiteDisposalPlan), @@ -489,6 +491,471 @@ namespace BLL CreateMan = Const.sysglyId, CreateDate = DateTime.Now }; + return result; + } + + public static HSSEData StatisticalData() + { + var thisUnitId = string.Empty; + var thisUnit = CommonService.GetIsThisUnit(); + if (thisUnit != null) thisUnitId = thisUnit.UnitId; + var baseUnit = UnitService.GetUnitByUnitId(thisUnitId); + Project_HSSEData_HiddenDangerDetailService.StatisticalAllProjectData(); + + var totalEnergyConsumption = ChemicalReportItemService.GetLatstTimeTotalEnergyConsumption(); + var incomeComprehensiveEnergyConsumption = + ChemicalReportItemService.GetLatstTimeIncomeComprehensiveEnergyConsumption(); + var newWaterConsumption = ChemicalReportItemService.GetLatstTimeNewWaterConsumption(); + + var table = new HSSEData_HSSE + { + UnitId = thisUnitId, + CollCropCode = baseUnit.CollCropCode, + UnitName = baseUnit.UnitName, + ReportDate = DateTime.Now.Date, + BeUnderConstructionNum = GetBeUnderConstruction().Count, + ShutdownNum = GetShutdown().Count, + JoinConstructionPersonNum = GetJoinConstructionPerson().Count, + MajorProjectsUnderConstructionNum = GetMajorProjectsUnderConstruction().Count, + TotalWorkingHour = GetTotalWorkingHour(), + LostWorkingHour = GetLostWorkingHour(), + SafeWorkingHour = GetSafeWorkingHour(), + SafeTrainNum = GetSafeTrain().Sum(x => x.TrainPersonNum), + SpecialTrainNum = GetSpecialTrain().Sum(x => x.TrainPersonNum), + SpecialOperationTrainNum = GetSpecialOperationTrain().Sum(x => x.TrainPersonNum), + EnvironmentalTrainNum = 0, + TotalEnergyConsumption = totalEnergyConsumption, + IncomeComprehensiveEnergyConsumption = incomeComprehensiveEnergyConsumption, + NewWaterConsumption = newWaterConsumption, + HeadOfficeInspectorGeneralNum = GetHeadOfficeInspectorGeneral().Count, + HeadOfficeFullTimeNum = GetHeadOfficeFullTime().Count, + BranchInspectorGeneralNum = GetBranchInspectorGeneral().Count, + BranchFullTimeNum = GetBranchFullTime().Count, + ProjectInspectorGeneralNum = GetProjectInspectorGeneral().Count, + ProjectFullTimeNum = GetProjectFullTime().Count, + ProjectSafetyMonitorNum = GetProjectSafetyMonitor().Count, + SafetyInjectionEngineer = GetSafetyInjectionEngineer().Count, + CertificateANum = GetCertificateA().Count, + CertificateBNum = GetCertificateB().Count, + CertificateCNum = GetCertificateC().Count, + SafetyCommitteeMeetingNum = GetSafetyCommitteeMeeting().Count, + EnterpriseTopicsMeetingNum = GetEnterpriseTopicsMeeting().Count, + ProjectSafetyLeadingGroupMeetingNum = GetProjectSafetyLeadingGroupMeeting().Count, + ProjectSafetyMeetingNum = GetProjectSafetyMeeting().Count, + CompanyLeadShiftCheckNum = GetCompanyLeadShiftCheck().Count, + CompanyComprehensiveCheckNum = GetCompanyComprehensiveCheck().Count, + CompanySpecialCheckNum = GetCompanySpecialCheck().Count, + ProjectLeadShiftCheckNum = GetProjectLeadShiftCheck().Count, + ProjectSpecialCheckNum = GetProjectSpecialCheck().Count, + ProjectMajorCheckNum = GetProjectMajorCheck().Count, + NearMissNum = GetNearMiss().Count, + RecordableEventNum = GetRecordableEvent().Count, + GeneralAccidentNum = GetGeneralAccident().Count, + MajorAccidentNum = GetMajorAccident().Count, + SeriousAccidentNum = GetSeriousAccident().Count, + SpecialSeriousAccidentNum = GetSpecialSeriousAccident().Count, + CompanyComprehensivePlanNum = GetCompanyComprehensivePlan().Count, + CompanySpecialPlanNum = GetCompanySpecialPlan().Count, + CompanyOnSiteDisposalPlan = GetCompanyOnSiteDisposalPlan().Count, + CompanyDrillNum = GetCompanyDrill().Count, + ProjectComprehensivePlanNum = GetProjectComprehensivePlan().Count, + ProjectSpecialPlanNum = GetProjectSpecialPlan().Count, + ProjectOnSiteDisposalPlan = GetProjectOnSiteDisposalPlan().Count, + ProjectDrillNum = GetProjectDrill().Count, + CostExtract = Convert.ToInt32(GetCostExtract().Sum(x => x.SUMCost)), + CostUse = Convert.ToInt32(GetCostUse().Sum(x => x.SUMCost)), + UseEquipmentNum = GetUseEquipment().Count, + SpecialEquipmentNum = GetSpecialEquipment().Count, + LicensesNum = GetLicenses().Count, + LicensesCloseNum = GetLicensesClose().Count, + GeneralClosedNum = GetGeneralHiddenRectificationOutputs().Sum(x => x.RecNum), + GeneralNotClosedNum = GetGeneralHiddenRectificationOutputs().Sum(x => x.NoRecNum), + MajorClosedNum = GetMajorHiddenRectificationOutputs().Sum(x => x.RecNum), + MajorNotClosedNum = GetMajorHiddenRectificationOutputs().Sum(x => x.NoRecNum), + GeneralRiskNum = GetSecurityRiskOutputs().Sum(x => x.GeneralRiskNum), + LowRiskNum = GetSecurityRiskOutputs().Sum(x => x.LowRiskNum), + MediumRiskNum = GetSecurityRiskOutputs().Sum(x => x.MediumRiskNum), + HighRiskNum = GetSecurityRiskOutputs().Sum(x => x.HighRiskNum), + CompletedNum = GetLargeEngineeringOutputs().Sum(x => x.CompletedNum), + TrainPersonNum = GetLargeEngineeringOutputs().Sum(x => x.TrainPersonNum), + ConstructionNum = GetLargeEngineeringOutputs().Sum(x => x.ConstructionNum), + FinishedNum = GetLargeEngineeringOutputs().Sum(x => x.FinishedNum), + SuperCompletedNum = GetLargeEngineeringOutputs().Sum(x => x.SuperCompletedNum), + SuperTrainPersonNum = GetLargeEngineeringOutputs().Sum(x => x.SuperTrainPersonNum), + SuperConstructionNum = GetLargeEngineeringOutputs().Sum(x => x.SuperConstructionNum), + SuperFinishedNum = GetLargeEngineeringOutputs().Sum(x => x.SuperFinishedNum), + CreateMan = Const.sysglyId, + CreateDate = DateTime.Now + }; + if (IsReportByToday()) + { + table.Id = GetTodayData().Id; + table.State = Const.CNCEC_State_1; + UpdateHSSEData_HSSE(table); + } + else + { + table.Id = SQLHelper.GetNewID(); + table.State = Const.CNCEC_State_0; + AddHSSEData_HSSE(table); + } + + var data = GetItemByHSSEData_HSSE(table, Project_HSSEData_HiddenDangerDetailService.GetTodayModel()); + return data; + } + + public static async Task StatisticalDataAsync() + { + var thisUnitId = string.Empty; + var thisUnit = CommonService.GetIsThisUnit(); + if (thisUnit != null) thisUnitId = thisUnit.UnitId; + var baseUnit = UnitService.GetUnitByUnitId(thisUnitId); + Project_HSSEData_HiddenDangerDetailService.StatisticalAllProjectData(); + + // 并行执行异步方法 + var totalEnergyConsumptionTask = ChemicalReportItemService.GetLatstTimeTotalEnergyConsumption(); + var incomeComprehensiveEnergyConsumptionTask = ChemicalReportItemService.GetLatstTimeIncomeComprehensiveEnergyConsumption(); + var newWaterConsumptionTask = ChemicalReportItemService.GetLatstTimeNewWaterConsumption(); + var securityRiskOutputListTask = HSSEData_HSSEService.GetSecurityRiskOutputsAsync(); + var largeEngineeringOutputsTask = HSSEData_HSSEService.GetLargeEngineeringOutputsAsync(); + + var safetyInjectionEngineerTask = HSSEData_HSSEService.GetSafetyInjectionEngineerAsync(); + var certificateATask = HSSEData_HSSEService.GetCertificateAAsync(); + var certificateBTask = HSSEData_HSSEService.GetCertificateBAsync(); + var certificateCTask = HSSEData_HSSEService.GetCertificateCAsync(); + var beUnderConstructionTask = HSSEData_HSSEService.GetBeUnderConstructionAsync(); + var shutdownTask = HSSEData_HSSEService.GetShutdownAsync(); + var joinConstructionPersonTask = HSSEData_HSSEService.GetJoinConstructionPersonAsync(); + var majorProjectsUnderConstructionTask = HSSEData_HSSEService.GetMajorProjectsUnderConstructionAsync(); + var totalWorkingHourTask = HSSEData_HSSEService.GetTotalWorkingHourAsync(); + var lostWorkingHourTask = HSSEData_HSSEService.GetLostWorkingHourAsync(); + var safeWorkingHourTask = HSSEData_HSSEService.GetSafeWorkingHourAsync(); + var safeTrainTask = HSSEData_HSSEService.GetSafeTrainAsync(); + var specialTrainTask = HSSEData_HSSEService.GetSpecialTrainAsync(); + var specialOperationTrainTask = HSSEData_HSSEService.GetSpecialOperationTrainAsync(); + var headOfficeInspectorGeneralTask = HSSEData_HSSEService.GetHeadOfficeInspectorGeneralAsync(); + var headOfficeFullTimeTask = HSSEData_HSSEService.GetHeadOfficeFullTimeAsync(); + var branchInspectorGeneralTask = HSSEData_HSSEService.GetBranchInspectorGeneralAsync(); + var branchFullTimeTask = HSSEData_HSSEService.GetBranchFullTimeAsync(); + var projectInspectorGeneralTask = HSSEData_HSSEService.GetProjectInspectorGeneralAsync(); + var projectFullTimeTask = HSSEData_HSSEService.GetProjectFullTimeAsync(); + var projectSafetyMonitorTask = HSSEData_HSSEService.GetProjectSafetyMonitorAsync(); + var safetyCommitteeMeetingTask = HSSEData_HSSEService.GetSafetyCommitteeMeetingAsync(); + var enterpriseTopicsMeetingTask = HSSEData_HSSEService.GetEnterpriseTopicsMeetingAsync(); + var projectSafetyLeadingGroupMeetingTask = HSSEData_HSSEService.GetProjectSafetyLeadingGroupMeetingAsync(); + var projectSafetyMeetingTask = HSSEData_HSSEService.GetProjectSafetyMeetingAsync(); + var companyLeadShiftCheckTask = HSSEData_HSSEService.GetCompanyLeadShiftCheckAsync(); + var companyComprehensiveCheckTask = HSSEData_HSSEService.GetCompanyComprehensiveCheckAsync(); + var companySpecialCheckTask = HSSEData_HSSEService.GetCompanySpecialCheckAsync(); + var projectLeadShiftCheckTask = HSSEData_HSSEService.GetProjectLeadShiftCheckAsync(); + var projectSpecialCheckTask = HSSEData_HSSEService.GetProjectSpecialCheckAsync(); + var projectMajorCheckTask = HSSEData_HSSEService.GetProjectMajorCheckAsync(); + var nearMissTask = HSSEData_HSSEService.GetNearMissAsync(); + var recordableEventTask = HSSEData_HSSEService.GetRecordableEventAsync(); + var generalAccidentTask = HSSEData_HSSEService.GetGeneralAccidentAsync(); + var majorAccidentTask = HSSEData_HSSEService.GetMajorAccidentAsync(); + var seriousAccidentTask = HSSEData_HSSEService.GetSeriousAccidentAsync(); + var specialSeriousAccidentTask = HSSEData_HSSEService.GetSpecialSeriousAccidentAsync(); + var companyComprehensivePlanTask = HSSEData_HSSEService.GetCompanyComprehensivePlanAsync(); + var companySpecialPlanTask = HSSEData_HSSEService.GetCompanySpecialPlanAsync(); + var companyOnSiteDisposalPlanTask = HSSEData_HSSEService.GetCompanyOnSiteDisposalPlanAsync(); + var companyDrillTask = HSSEData_HSSEService.GetCompanyDrillAsync(); + var projectComprehensivePlanTask = HSSEData_HSSEService.GetProjectComprehensivePlanAsync(); + var projectSpecialPlanTask = HSSEData_HSSEService.GetProjectSpecialPlanAsync(); + var projectOnSiteDisposalPlanTask = HSSEData_HSSEService.GetProjectOnSiteDisposalPlanAsync(); + var projectDrillTask = HSSEData_HSSEService.GetProjectDrillAsync(); + var costExtractTask = HSSEData_HSSEService.GetCostExtractAsync(); + var costUseTask = HSSEData_HSSEService.GetCostUseAsync(); + var useEquipmentTask = HSSEData_HSSEService.GetUseEquipmentAsync(); + var specialEquipmentTask = HSSEData_HSSEService.GetSpecialEquipmentAsync(); + var licensesTask = HSSEData_HSSEService.GetLicensesAsync(); + var licensesCloseTask = HSSEData_HSSEService.GetLicensesCloseAsync(); + var generalHiddenRectificationOutputsTask = HSSEData_HSSEService.GetGeneralHiddenRectificationOutputsAsync(); + var majorHiddenRectificationOutputsTask = HSSEData_HSSEService.GetMajorHiddenRectificationOutputsAsync(); + + // 等待所有异步方法执行完成 + await Task.WhenAll( + securityRiskOutputListTask, + largeEngineeringOutputsTask, + safetyInjectionEngineerTask, + certificateATask, + certificateBTask, + certificateCTask, + beUnderConstructionTask, + shutdownTask, + joinConstructionPersonTask, + majorProjectsUnderConstructionTask, + totalWorkingHourTask, + lostWorkingHourTask, + safeWorkingHourTask, + safeTrainTask, + specialTrainTask, + specialOperationTrainTask, + headOfficeInspectorGeneralTask, + headOfficeFullTimeTask, + branchInspectorGeneralTask, + branchFullTimeTask, + projectInspectorGeneralTask, + projectFullTimeTask, + projectSafetyMonitorTask, + safetyCommitteeMeetingTask, + enterpriseTopicsMeetingTask, + projectSafetyLeadingGroupMeetingTask, + projectSafetyMeetingTask, + companyLeadShiftCheckTask, + companyComprehensiveCheckTask, + companySpecialCheckTask, + projectLeadShiftCheckTask, + projectSpecialCheckTask, + projectMajorCheckTask, + nearMissTask, + recordableEventTask, + generalAccidentTask, + majorAccidentTask, + seriousAccidentTask, + specialSeriousAccidentTask, + companyComprehensivePlanTask, + companySpecialPlanTask, + companyOnSiteDisposalPlanTask, + companyDrillTask, + projectComprehensivePlanTask, + projectSpecialPlanTask, + projectOnSiteDisposalPlanTask, + projectDrillTask, + costExtractTask, + costUseTask, + useEquipmentTask, + specialEquipmentTask, + licensesTask, + licensesCloseTask, + generalHiddenRectificationOutputsTask, + majorHiddenRectificationOutputsTask + ); + + + // 统一获取异步方法的返回值 + var totalEnergyConsumption = totalEnergyConsumptionTask; + var incomeComprehensiveEnergyConsumption = incomeComprehensiveEnergyConsumptionTask; + var newWaterConsumption = newWaterConsumptionTask; + var safetyInjectionEngineerList = await safetyInjectionEngineerTask; + var certificateAList = await certificateATask; + var certificateBList = await certificateBTask; + var certificateCList = await certificateCTask; + var beUnderConstructionList = await beUnderConstructionTask; + var shutdownList = await shutdownTask; + var joinConstructionPersonList = await joinConstructionPersonTask; + var majorProjectsUnderConstructionList = await majorProjectsUnderConstructionTask; + var totalWorkingHour = await totalWorkingHourTask; + var lostWorkingHour = await lostWorkingHourTask; + var safeWorkingHour = await safeWorkingHourTask; + var safeTrainList = await safeTrainTask; + var specialTrainList = await specialTrainTask; + var specialOperationTrainList = await specialOperationTrainTask; + var headOfficeInspectorGeneralList = await headOfficeInspectorGeneralTask; + var headOfficeFullTimeList = await headOfficeFullTimeTask; + var branchInspectorGeneralList = await branchInspectorGeneralTask; + var branchFullTimeList = await branchFullTimeTask; + var projectInspectorGeneralList = await projectInspectorGeneralTask; + var projectFullTimeList = await projectFullTimeTask; + var projectSafetyMonitorList = await projectSafetyMonitorTask; + var safetyCommitteeMeetingList = await safetyCommitteeMeetingTask; + var enterpriseTopicsMeetingList = await enterpriseTopicsMeetingTask; + var projectSafetyLeadingGroupMeetingList = await projectSafetyLeadingGroupMeetingTask; + var projectSafetyMeetingList = await projectSafetyMeetingTask; + var companyLeadShiftCheckList = await companyLeadShiftCheckTask; + var companyComprehensiveCheckList = await companyComprehensiveCheckTask; + var companySpecialCheckList = await companySpecialCheckTask; + var projectLeadShiftCheckList = await projectLeadShiftCheckTask; + var projectSpecialCheckList = await projectSpecialCheckTask; + var projectMajorCheckList = await projectMajorCheckTask; + var nearMissList = await nearMissTask; + var recordableEventList = await recordableEventTask; + var generalAccidentList = await generalAccidentTask; + var majorAccidentList = await majorAccidentTask; + var seriousAccidentList = await seriousAccidentTask; + var specialSeriousAccidentList = await specialSeriousAccidentTask; + var companyComprehensivePlanList = await companyComprehensivePlanTask; + var companySpecialPlanList = await companySpecialPlanTask; + var companyOnSiteDisposalPlanList = await companyOnSiteDisposalPlanTask; + var companyDrillList = await companyDrillTask; + var projectComprehensivePlanList = await projectComprehensivePlanTask; + var projectSpecialPlanList = await projectSpecialPlanTask; + var projectOnSiteDisposalPlanList = await projectOnSiteDisposalPlanTask; + var projectDrillList = await projectDrillTask; + var costExtract = await costExtractTask; + var costUseList = await costUseTask; + var useEquipmentList = await useEquipmentTask; + var specialEquipmentList = await specialEquipmentTask; + var licensesList = await licensesTask; + var licensesCloseList = await licensesCloseTask; + var generalHiddenRectificationOutputsList = await generalHiddenRectificationOutputsTask; + var majorHiddenRectificationOutputsList = await majorHiddenRectificationOutputsTask; + + // 构造结果对象 + var table = new HSSEData_HSSE + { + UnitId = thisUnitId, + CollCropCode = baseUnit.CollCropCode, + UnitName = baseUnit.UnitName, + ReportDate = DateTime.Now.Date, + BeUnderConstructionNum = beUnderConstructionList.Count(), + ShutdownNum = shutdownList.Count(), + SafetyInjectionEngineer = safetyInjectionEngineerList.Count(), + CertificateANum = certificateAList.Count(), + CertificateBNum = certificateBList.Count(), + CertificateCNum = certificateCList.Count(), + JoinConstructionPersonNum = joinConstructionPersonList.Count(), + MajorProjectsUnderConstructionNum = majorProjectsUnderConstructionList.Count(), + TotalWorkingHour = totalWorkingHour, + LostWorkingHour = lostWorkingHour, + SafeWorkingHour = safeWorkingHour, + SafeTrainNum = safeTrainList.Sum(x => x.TrainPersonNum), + SpecialTrainNum = specialTrainList.Sum(x => x.TrainPersonNum), + SpecialOperationTrainNum = specialOperationTrainList.Sum(x => x.TrainPersonNum), + EnvironmentalTrainNum = 0, + TotalEnergyConsumption = totalEnergyConsumption, + IncomeComprehensiveEnergyConsumption = incomeComprehensiveEnergyConsumption, + NewWaterConsumption = newWaterConsumption, + HeadOfficeInspectorGeneralNum = headOfficeInspectorGeneralList.Count, + HeadOfficeFullTimeNum = headOfficeFullTimeList.Count, + BranchInspectorGeneralNum = branchInspectorGeneralList.Count, + BranchFullTimeNum = branchFullTimeList.Count, + ProjectInspectorGeneralNum = projectInspectorGeneralList.Count, + ProjectFullTimeNum = projectFullTimeList.Count, + ProjectSafetyMonitorNum = projectSafetyMonitorList.Count, + SafetyCommitteeMeetingNum = safetyCommitteeMeetingList.Count(), + EnterpriseTopicsMeetingNum = enterpriseTopicsMeetingList.Count(), + ProjectSafetyLeadingGroupMeetingNum = projectSafetyLeadingGroupMeetingList.Count(), + ProjectSafetyMeetingNum = projectSafetyMeetingList.Count(), + CompanyLeadShiftCheckNum = companyLeadShiftCheckList.Count(), + CompanyComprehensiveCheckNum = companyComprehensiveCheckList.Count(), + CompanySpecialCheckNum = companySpecialCheckList.Count(), + ProjectLeadShiftCheckNum = projectLeadShiftCheckList.Count(), + ProjectSpecialCheckNum = projectSpecialCheckList.Count(), + ProjectMajorCheckNum = projectMajorCheckList.Count(), + NearMissNum = nearMissList.Count(), + RecordableEventNum = recordableEventList.Count(), + GeneralAccidentNum = generalAccidentList.Count(), + MajorAccidentNum = majorAccidentList.Count(), + SeriousAccidentNum = seriousAccidentList.Count(), + SpecialSeriousAccidentNum = specialSeriousAccidentList.Count(), + CompanyComprehensivePlanNum = companyComprehensivePlanList.Count(), + CompanySpecialPlanNum = companySpecialPlanList.Count(), + CompanyOnSiteDisposalPlan = companyOnSiteDisposalPlanList.Count(), + CompanyDrillNum = companyDrillList.Count(), + ProjectComprehensivePlanNum = projectComprehensivePlanList.Count(), + ProjectSpecialPlanNum = projectSpecialPlanList.Count(), + ProjectOnSiteDisposalPlan = projectOnSiteDisposalPlanList.Count(), + ProjectDrillNum = projectDrillList.Count(), + CostExtract = Convert.ToInt32(costExtract.Sum(x => x.SUMCost)), + CostUse = Convert.ToInt32(costUseList.Sum(x => x.SUMCost)), + UseEquipmentNum = useEquipmentList.Count(), + SpecialEquipmentNum = specialEquipmentList.Count(), + LicensesNum = licensesList.Count(), + LicensesCloseNum = licensesCloseList.Count(), + GeneralClosedNum = generalHiddenRectificationOutputsList.Sum(x => x.RecNum), + GeneralNotClosedNum = generalHiddenRectificationOutputsList.Sum(x => x.NoRecNum), + MajorClosedNum = majorHiddenRectificationOutputsList.Sum(x => x.RecNum), + MajorNotClosedNum = majorHiddenRectificationOutputsList.Sum(x => x.NoRecNum), + LowRiskNum = securityRiskOutputListTask.Result.Sum(x => x.LowRiskNum), + GeneralRiskNum = securityRiskOutputListTask.Result.Sum(x => x.GeneralRiskNum), + MediumRiskNum = securityRiskOutputListTask.Result.Sum(x => x.MediumRiskNum), + HighRiskNum = securityRiskOutputListTask.Result.Sum(x => x.HighRiskNum), + CompletedNum = largeEngineeringOutputsTask.Result.Sum(x => x.CompletedNum), + TrainPersonNum = largeEngineeringOutputsTask.Result.Sum(x => x.TrainPersonNum), + ConstructionNum = largeEngineeringOutputsTask.Result.Sum(x => x.ConstructionNum), + FinishedNum = largeEngineeringOutputsTask.Result.Sum(x => x.FinishedNum), + SuperCompletedNum = largeEngineeringOutputsTask.Result.Sum(x => x.SuperCompletedNum), + SuperTrainPersonNum = largeEngineeringOutputsTask.Result.Sum(x => x.SuperTrainPersonNum), + SuperConstructionNum = largeEngineeringOutputsTask.Result.Sum(x => x.SuperConstructionNum) + }; + + #region 添加项目统计数据 + + Project_HSSEData_HSSEService.DeleteProject_HSSEData_HSSEByDate(DateTime.Now.Date); + foreach (var projectid in BeUnderConstructionList) + { + var projectHsseData = new Project_HSSEData_HSSE + { + Id = SQLHelper.GetNewID(), + ProjectId = projectid, + UnitId = thisUnitId, + CollCropCode = baseUnit.CollCropCode, + UnitName = baseUnit.UnitName, + ReportDate = DateTime.Now.Date, + JoinConstructionPersonNum = joinConstructionPersonList.Count(x => x.ProjectId == projectid), + MajorProjectsUnderConstructionNum = majorProjectsUnderConstructionList.Count(x => x.ProjectId == projectid), + TotalWorkingHour = 0,//工时数据取自集团报表,项目无法提取 + LostWorkingHour = 0, + SafeWorkingHour = 0, + SafeTrainNum = safeTrainList.Where(x => x.ProjectId == projectid).Sum(x => x.TrainPersonNum), + SpecialTrainNum = specialTrainList.Where(x => x.ProjectId == projectid).Sum(x => x.TrainPersonNum), + SpecialOperationTrainNum = specialOperationTrainList.Where(x => x.ProjectId == projectid).Sum(x => x.TrainPersonNum), + EnvironmentalTrainNum = 0, + TotalEnergyConsumption = 0, + IncomeComprehensiveEnergyConsumption = 0, + NewWaterConsumption = 0, + HeadOfficeInspectorGeneralNum = 0, + HeadOfficeFullTimeNum =0, + BranchInspectorGeneralNum = 0, + BranchFullTimeNum = 0, + SafetyInjectionEngineer = safetyInjectionEngineerList.Count(x => x.ProjectId == projectid), + EnterpriseTopicsMeetingNum = safetyInjectionEngineerList.Count(x => x.ProjectId == projectid), + CertificateANum = certificateAList.Count(x => x.ProjectId == projectid), + CertificateBNum = certificateBList.Count(x => x.ProjectId == projectid), + CertificateCNum = certificateCList.Count(x => x.ProjectId == projectid), + ProjectInspectorGeneralNum = projectInspectorGeneralList.Count(x => x.ProjectId == projectid), + ProjectFullTimeNum = projectFullTimeList.Count(x => x.ProjectId == projectid), + ProjectSafetyMonitorNum = projectSafetyMonitorList.Count(x => x.ProjectId == projectid), + ProjectSafetyLeadingGroupMeetingNum = projectSafetyLeadingGroupMeetingList.Count(x => x.ProjectId == projectid), + ProjectSafetyMeetingNum = projectSafetyMeetingList.Count(x => x.ProjectId == projectid), + CompanyLeadShiftCheckNum = companyLeadShiftCheckList.Count(x => x.ProjectId == projectid), + CompanyComprehensiveCheckNum = companyComprehensiveCheckList.Count(x => x.ProjectId == projectid), + CompanySpecialCheckNum = companySpecialCheckList.Count(x => x.ProjectId == projectid), + ProjectLeadShiftCheckNum = projectLeadShiftCheckList.Count(x => x.ProjectId == projectid), + ProjectSpecialCheckNum = projectSpecialCheckList.Count(x => x.ProjectId == projectid), + ProjectMajorCheckNum = projectMajorCheckList.Count(x => x.ProjectId == projectid), + NearMissNum = nearMissList.Count(x => x.ProjectId == projectid), + RecordableEventNum = recordableEventList.Count(x => x.ProjectId == projectid), + GeneralAccidentNum = generalAccidentList.Count(x => x.ProjectId == projectid), + MajorAccidentNum = majorAccidentList.Count(x => x.ProjectId == projectid), + SeriousAccidentNum = seriousAccidentList.Count(x => x.ProjectId == projectid), + SpecialSeriousAccidentNum = specialSeriousAccidentList.Count(x => x.ProjectId == projectid), + CompanyComprehensivePlanNum = 0, + CompanySpecialPlanNum = 0, + CompanyOnSiteDisposalPlan =0, + CompanyDrillNum = 0, + ProjectComprehensivePlanNum = projectComprehensivePlanList.Count(x => x.ProjectId == projectid), + ProjectSpecialPlanNum = projectSpecialPlanList.Count(x => x.ProjectId == projectid), + ProjectOnSiteDisposalPlan = projectOnSiteDisposalPlanList.Count(x => x.ProjectId == projectid), + ProjectDrillNum = projectDrillList.Count(x => x.ProjectId == projectid), + CostExtract = Convert.ToInt32(costExtract.Where(x => x.ProjectId == projectid).Sum(x => x.SUMCost)), + CostUse = Convert.ToInt32(costUseList.Where(x => x.ProjectId == projectid).Sum(x => x.SUMCost)), + UseEquipmentNum = useEquipmentList.Count(x => x.ProjectId == projectid), + SpecialEquipmentNum = specialEquipmentList.Count(x => x.ProjectId == projectid), + LicensesNum = licensesList.Count(x => x.ProjectId == projectid), + LicensesCloseNum = licensesCloseList.Count(x => x.ProjectId == projectid), + GeneralClosedNum = generalHiddenRectificationOutputsList.Where(x => x.ProjectId == projectid).Sum(x => x.RecNum), + GeneralNotClosedNum = generalHiddenRectificationOutputsList.Where(x => x.ProjectId == projectid).Sum(x => x.NoRecNum), + MajorClosedNum = majorHiddenRectificationOutputsList.Where(x => x.ProjectId == projectid).Sum(x => x.RecNum), + MajorNotClosedNum = majorHiddenRectificationOutputsList.Where(x => x.ProjectId == projectid).Sum(x => x.NoRecNum), + LowRiskNum = securityRiskOutputListTask.Result.Where(x => x.ProjectId == projectid).Sum(x => x.LowRiskNum), + GeneralRiskNum = securityRiskOutputListTask.Result.Where(x => x.ProjectId == projectid).Sum(x => x.GeneralRiskNum), + MediumRiskNum = securityRiskOutputListTask.Result.Where(x => x.ProjectId == projectid).Sum(x => x.MediumRiskNum), + HighRiskNum = securityRiskOutputListTask.Result.Where(x => x.ProjectId == projectid).Sum(x => x.HighRiskNum), + CompletedNum = largeEngineeringOutputsTask.Result.Where(x => x.ProjectId == projectid).Sum(x => x.CompletedNum), + TrainPersonNum = largeEngineeringOutputsTask.Result.Where(x => x.ProjectId == projectid).Sum(x => x.TrainPersonNum), + ConstructionNum = largeEngineeringOutputsTask.Result.Where(x => x.ProjectId == projectid).Sum(x => x.ConstructionNum), + FinishedNum = largeEngineeringOutputsTask.Result.Where(x => x.ProjectId == projectid).Sum(x => x.FinishedNum), + SuperCompletedNum = largeEngineeringOutputsTask.Result.Where(x => x.ProjectId == projectid).Sum(x => x.SuperCompletedNum), + SuperTrainPersonNum = largeEngineeringOutputsTask.Result.Where(x => x.ProjectId == projectid).Sum(x => x.SuperTrainPersonNum), + SuperConstructionNum = largeEngineeringOutputsTask.Result.Where(x => x.ProjectId == projectid).Sum(x => x.SuperConstructionNum) + }; + Project_HSSEData_HSSEService.AddProject_HSSEData_HSSE(projectHsseData); + } + + #endregion + if (IsReportByToday()) { table.Id = GetTodayData().Id; @@ -506,6 +973,120 @@ namespace BLL return data; } + //public static HSSEData StatisticalDataOld() + //{ + // var thisUnitId = string.Empty; + // var thisUnit = CommonService.GetIsThisUnit(); + // if (thisUnit != null) thisUnitId = thisUnit.UnitId; + // var baseUnit = UnitService.GetUnitByUnitId(thisUnitId); + // Project_HSSEData_HSSEService.StatisticalAllProjectData(); + // Project_HSSEData_HiddenDangerDetailService.StatisticalAllProjectData(); + + // var projectData = (from x in Funs.DB.Project_HSSEData_HSSE + // where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date + // select x).ToList(); + // var totalEnergyConsumption = ChemicalReportItemService.GetLatstTimeTotalEnergyConsumption(); + // var incomeComprehensiveEnergyConsumption = + // ChemicalReportItemService.GetLatstTimeIncomeComprehensiveEnergyConsumption(); + // var newWaterConsumption = ChemicalReportItemService.GetLatstTimeNewWaterConsumption(); + + // var table = new HSSEData_HSSE + // { + // UnitId = thisUnitId, + // CollCropCode = baseUnit.CollCropCode, + // UnitName = baseUnit.UnitName, + // ReportDate = DateTime.Now.Date, + // BeUnderConstructionNum = projectData.Sum(x => x.BeUnderConstructionNum), + // ShutdownNum = projectData.Sum(x => x.ShutdownNum), + // JoinConstructionPersonNum = projectData.Sum(x => x.JoinConstructionPersonNum), + // MajorProjectsUnderConstructionNum = projectData.Sum(x => x.MajorProjectsUnderConstructionNum), + // TotalWorkingHour = projectData.Sum(x => x.TotalWorkingHour), + // LostWorkingHour = projectData.Sum(x => x.LostWorkingHour), + // SafeWorkingHour = projectData.Sum(x => x.SafeWorkingHour), + // SafeTrainNum = projectData.Sum(x => x.SafeTrainNum), + // SpecialTrainNum = projectData.Sum(x => x.SpecialTrainNum), + // SpecialOperationTrainNum = projectData.Sum(x => x.SpecialOperationTrainNum), + // EnvironmentalTrainNum = projectData.Sum(x => x.EnvironmentalTrainNum), + // TotalEnergyConsumption = totalEnergyConsumption, + // IncomeComprehensiveEnergyConsumption = incomeComprehensiveEnergyConsumption, + // NewWaterConsumption = newWaterConsumption, + // HeadOfficeInspectorGeneralNum = GetHeadOfficeInspectorGeneralNum(), + // HeadOfficeFullTimeNum = GetHeadOfficeFullTimeNum(), + // BranchInspectorGeneralNum = GetBranchInspectorGeneralNum(), + // BranchFullTimeNum = GetBranchFullTimeNum(), + // ProjectInspectorGeneralNum = projectData.Sum(x => x.ProjectInspectorGeneralNum), + // ProjectFullTimeNum = projectData.Sum(x => x.ProjectFullTimeNum), + // ProjectSafetyMonitorNum = projectData.Sum(x => x.ProjectSafetyMonitorNum), + // SafetyInjectionEngineer = projectData.Sum(x => x.SafetyInjectionEngineer), + // CertificateANum = projectData.Sum(x => x.CertificateANum), + // CertificateBNum = projectData.Sum(x => x.CertificateBNum), + // CertificateCNum = projectData.Sum(x => x.CertificateCNum), + // SafetyCommitteeMeetingNum = GetSafetyCommitteeMeetingNum(), + // EnterpriseTopicsMeetingNum = GetEnterpriseTopicsMeetingNum(), + // ProjectSafetyLeadingGroupMeetingNum = projectData.Sum(x => x.ProjectSafetyLeadingGroupMeetingNum), + // ProjectSafetyMeetingNum = projectData.Sum(x => x.ProjectSafetyMeetingNum), + // // CompanyLeadShiftCheckNum = GetCompanyLeadShiftCheckNum(), + // // CompanyComprehensiveCheckNum = GetCompanyComprehensiveCheckNum(), + // // CompanySpecialCheckNum = GetCompanySpecialCheckNum(), + // ProjectLeadShiftCheckNum = projectData.Sum(x => x.ProjectLeadShiftCheckNum), + // ProjectSpecialCheckNum = projectData.Sum(x => x.ProjectSpecialCheckNum), + // ProjectMajorCheckNum = projectData.Sum(x => x.ProjectMajorCheckNum), + // NearMissNum = projectData.Sum(x => x.NearMissNum), + // RecordableEventNum = projectData.Sum(x => x.RecordableEventNum), + // GeneralAccidentNum = projectData.Sum(x => x.GeneralAccidentNum), + // MajorAccidentNum = projectData.Sum(x => x.MajorAccidentNum), + // SeriousAccidentNum = projectData.Sum(x => x.SeriousAccidentNum), + // SpecialSeriousAccidentNum = projectData.Sum(x => x.SpecialSeriousAccidentNum), + // //CompanyComprehensivePlanNum = GetCompanyComprehensivePlan(), + // // CompanySpecialPlanNum = GetCompanySpecialPlan(), + // // CompanyOnSiteDisposalPlan = GetCompanyOnSiteDisposalPlan(), + // // CompanyDrillNum = GetCompanyDrill(), + // ProjectComprehensivePlanNum = projectData.Sum(x => x.ProjectComprehensivePlanNum), + // ProjectSpecialPlanNum = projectData.Sum(x => x.ProjectSpecialPlanNum), + // ProjectOnSiteDisposalPlan = projectData.Sum(x => x.ProjectOnSiteDisposalPlan), + // ProjectDrillNum = projectData.Sum(x => x.ProjectDrillNum), + // CostExtract = projectData.Sum(x => x.CostExtract), + // CostUse = projectData.Sum(x => x.CostUse), + // UseEquipmentNum = projectData.Sum(x => x.UseEquipmentNum), + // SpecialEquipmentNum = projectData.Sum(x => x.SpecialEquipmentNum), + // LicensesNum = projectData.Sum(x => x.LicensesNum), + // LicensesCloseNum = projectData.Sum(x => x.LicensesCloseNum), + // GeneralClosedNum = projectData.Sum(x => x.GeneralClosedNum), + // GeneralNotClosedNum = projectData.Sum(x => x.GeneralNotClosedNum), + // MajorClosedNum = projectData.Sum(x => x.MajorClosedNum), + // MajorNotClosedNum = projectData.Sum(x => x.MajorNotClosedNum), + // GeneralRiskNum = projectData.Sum(x => x.GeneralRiskNum), + // LowRiskNum = projectData.Sum(x => x.LowRiskNum), + // MediumRiskNum = projectData.Sum(x => x.MediumRiskNum), + // HighRiskNum = projectData.Sum(x => x.HighRiskNum), + // CompletedNum = projectData.Sum(x => x.CompletedNum), + // TrainPersonNum = projectData.Sum(x => x.TrainPersonNum), + // ConstructionNum = projectData.Sum(x => x.ConstructionNum), + // FinishedNum = projectData.Sum(x => x.FinishedNum), + // SuperCompletedNum = projectData.Sum(x => x.SuperCompletedNum), + // SuperTrainPersonNum = projectData.Sum(x => x.SuperTrainPersonNum), + // SuperConstructionNum = projectData.Sum(x => x.SuperConstructionNum), + // SuperFinishedNum = projectData.Sum(x => x.SuperFinishedNum), + // CreateMan = Const.sysglyId, + // CreateDate = DateTime.Now + // }; + // if (IsReportByToday()) + // { + // table.Id = GetTodayData().Id; + // table.State = Const.CNCEC_State_1; + // UpdateHSSEData_HSSE(table); + // } + // else + // { + // table.Id = SQLHelper.GetNewID(); + // table.State = Const.CNCEC_State_0; + // AddHSSEData_HSSE(table); + // } + + // var data = GetItemByHSSEData_HSSE(table, Project_HSSEData_HiddenDangerDetailService.GetTodayModel()); + // return data; + //} + public static void UpdateHSSEData_HSSE(HSSEData_HSSE newtable) { using (var db = new SGGLDB(Funs.ConnString)) @@ -528,6 +1109,7 @@ namespace BLL table.SafeTrainNum = newtable.SafeTrainNum; table.SpecialTrainNum = newtable.SpecialTrainNum; table.SpecialOperationTrainNum = newtable.SpecialOperationTrainNum; + table.EnvironmentalTrainNum = newtable.EnvironmentalTrainNum; table.TotalEnergyConsumption = newtable.TotalEnergyConsumption; table.IncomeComprehensiveEnergyConsumption = newtable.IncomeComprehensiveEnergyConsumption; table.NewWaterConsumption = newtable.NewWaterConsumption; @@ -596,79 +1178,584 @@ namespace BLL } } + + + + #region 安监人员数据 /// /// 获取企业总部总监人数 /// /// - public static int GetHeadOfficeInspectorGeneralNum() + public static List GetHeadOfficeInspectorGeneral() { var unitId = string.Empty; var thisUnit = CommonService.GetIsThisUnit(); if (thisUnit != null) unitId = thisUnit.UnitId; var result = (from x in Funs.DB.Person_CompanyBranchPerson - where x.IsOnJob == true && x.WorkPostId == Const.WorkPost_HSSEDirector && x.UnitId == unitId - select x).Count(); + join u in Funs.DB.Base_Unit on x.UnitId equals u.UnitId into uGroup + from u in uGroup.DefaultIfEmpty() + where x.IsOnJob == true && x.WorkPostId == Const.WorkPost_HSSEDirector && x.UnitId == unitId && x.IdentityCard != null + select new Model.OfSafetySupervisorsOutput + { + ProjectId = "", + ProjectName = "", + UnitName = u.UnitName, + Name = x.PersonName, + Sex = x.Sex == null ? "" : (x.Sex == "1" ? "男" : "女"), + IdentityCard = x.IdentityCard, + WorkPostName = PostService.GetPostNameById(x.WorkPostId), + Phone = x.Telephone + }).ToList(); + result = result + .GroupBy(x => x.IdentityCard) + .Select(g => g.FirstOrDefault()) + .ToList(); return result; } + /// + /// 获取企业总部总监人数(异步) + /// + /// + public static async Task> GetHeadOfficeInspectorGeneralAsync() + { + return await Task.Run(GetHeadOfficeInspectorGeneral); + } + /// /// 获取企业总部专职人数 /// /// - public static int GetHeadOfficeFullTimeNum() + public static List GetHeadOfficeFullTime() { 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.IsHsse == true && x.UnitId == unitId - select x).Count(); + 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.Base_WorkPost on x.WorkPostId equals y.WorkPostId + where x.IsOnJob == true && y.IsHsse == true && x.UnitId == unitId && x.IdentityCard != null + select new Model.OfSafetySupervisorsOutput + { + ProjectName = "", + UnitName = u.UnitName, + Name = x.PersonName, + Sex = x.Sex == null ? "" : (x.Sex == "1" ? "男" : "女"), + IdentityCard = x.IdentityCard, + WorkPostName = PostService.GetPostNameById(x.WorkPostId), + Phone = x.Telephone + }).ToList(); + result = result + .GroupBy(x => x.IdentityCard) + .Select(g => g.FirstOrDefault()) + .ToList(); return result; } - /// - /// 获取分支机构总监人数 + /// 获取企业总部专职人数(异步) /// /// - public static int GetBranchInspectorGeneralNum() + public static async Task> GetHeadOfficeFullTimeAsync() { - var unitId = string.Empty; - var thisUnit = CommonService.GetIsThisUnit(); - if (thisUnit != null) unitId = thisUnit.UnitId; - var result = (from x in Funs.DB.Person_CompanyBranchPerson - where x.IsOnJob == true && x.WorkPostId == Const.WorkPost_HSSEDirector && x.UnitId != unitId - select x).Count(); - return result; + return await Task.Run(GetHeadOfficeFullTime); } /// /// 获取分支机构专职人数 /// /// - public static int GetBranchFullTimeNum() + public static List GetBranchFullTime() { 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.IsHsse == true && x.UnitId != unitId - select x).Count(); + 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.Base_WorkPost on x.WorkPostId equals y.WorkPostId + where x.IsOnJob == true && y.IsHsse == true && x.UnitId != unitId && x.IdentityCard != null + select new Model.OfSafetySupervisorsOutput + { + ProjectName = "", + UnitName = u.UnitName, + Name = x.PersonName, + Sex = x.Sex == null ? "" : (x.Sex == "1" ? "男" : "女"), + IdentityCard = x.IdentityCard, + WorkPostName = PostService.GetPostNameById(x.WorkPostId), + Phone = x.Telephone + }).ToList(); + result = result + .GroupBy(x => x.IdentityCard) + .Select(g => g.FirstOrDefault()) + .ToList(); + return result; + } + /// + /// 获取分支机构专职人数(异步) + /// + /// + public static async Task> GetBranchFullTimeAsync() + { + + return await Task.Run(GetBranchFullTime); + } + + /// + /// 获取分支机构总监人数 + /// + /// + public static List GetBranchInspectorGeneral() + { + var unitId = string.Empty; + var thisUnit = CommonService.GetIsThisUnit(); + if (thisUnit != null) unitId = thisUnit.UnitId; + var result = (from x in Funs.DB.Person_CompanyBranchPerson + join u in Funs.DB.Base_Unit on x.UnitId equals u.UnitId into uGroup + from u in uGroup.DefaultIfEmpty() + where x.IsOnJob == true && x.WorkPostId == Const.WorkPost_HSSEDirector && x.UnitId != unitId && x.IdentityCard != null + select new Model.OfSafetySupervisorsOutput + { + ProjectName = "", + UnitName = u.UnitName, + Name = x.PersonName, + Sex = x.Sex == null ? "" : (x.Sex == "1" ? "男" : "女"), + IdentityCard = x.IdentityCard, + WorkPostName = PostService.GetPostNameById(x.WorkPostId), + Phone = x.Telephone + }).ToList(); + result = result + .GroupBy(x => x.IdentityCard) + .Select(g => g.FirstOrDefault()) + .ToList(); + return result; + } + /// + /// 获取分支机构总监人数(异步) + /// + /// + public static async Task> GetBranchInspectorGeneralAsync() + { + + return await Task.Run(GetBranchInspectorGeneral); + } + /// + /// 获取项目总监人数 + /// + /// + public static List GetProjectInspectorGeneral() + { + var result = (from x in Funs.DB.SitePerson_Person + 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.Base_WorkPost on x.WorkPostId equals y.WorkPostId + where BeUnderConstructionList.Contains(p.ProjectId) && + x.WorkPostId == Const.WorkPost_ProjectHSSEDirector && x.IsUsed == true && x.IdentityCard != null + 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 = PostService.GetPostNameById(x.WorkPostId), + Phone = x.Telephone + }).ToList(); + result = result + .GroupBy(x => x.IdentityCard) + .Select(g => g.FirstOrDefault()) + .ToList(); + return result; + } + /// + /// 获取项目总监人数(异步) + /// + /// + public static async Task> GetProjectInspectorGeneralAsync() + { + return await Task.Run(GetProjectInspectorGeneral); + } + + /// + /// 获取项目专职人数 + /// + /// + public static List GetProjectFullTime() + { + var result = (from x in Funs.DB.SitePerson_Person + 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.Base_WorkPost on x.WorkPostId equals y.WorkPostId + where BeUnderConstructionList.Contains(p.ProjectId) && y.IsHsse == true && x.IsUsed == true && x.IdentityCard != null + 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 = PostService.GetPostNameById(x.WorkPostId), + Phone = x.Telephone + }).ToList(); + result = result + .GroupBy(x => x.IdentityCard) + .Select(g => g.FirstOrDefault()) + .ToList(); + return result; + } + /// + /// 获取项目专职人数(异步) + /// + /// + public static async Task> GetProjectFullTimeAsync() + { + return await Task.Run(GetProjectFullTime); + } + + /// + /// 获取项目安全监护人数 + /// + /// + public static List GetProjectSafetyMonitor() + { + var result = (from x in Funs.DB.SitePerson_Person + where x.IsSafetyMonitoring == true && x.IsUsed == true && x.IdentityCard != null + 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 post in Funs.DB.Base_WorkPost on x.WorkPostId equals post.WorkPostId into postGroup + from post in postGroup.DefaultIfEmpty() + where BeUnderConstructionList.Contains(p.ProjectId) + 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 = post.WorkPostName, + Phone = x.Telephone + }).ToList(); + result = result + .GroupBy(x => x.IdentityCard) + .Select(g => g.FirstOrDefault()) + .ToList(); + return result; + } + /// + /// 获取项目安全监护人数(异步) + /// + /// + public static async Task> GetProjectSafetyMonitorAsync() + { + return await Task.Run(GetProjectSafetyMonitor); + + } + + /// + /// 获取在岗执业注安师 + /// + /// + public static List GetSafetyInjectionEngineer() + { + var result = (from x in Funs.DB.SitePerson_Person + + 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.QualityAudit_PersonQuality on x.PersonId equals y.PersonId + join z in Funs.DB.Base_Certificate on y.CertificateId equals z.CertificateId + where BeUnderConstructionList.Contains(p.ProjectId) && z.IsRegisterHSSE == true && x.IsUsed == true && x.IdentityCard != null + 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 = PostService.GetPostNameById(x.WorkPostId), + Phone = x.Telephone + }).ToList(); + + var query2 = (from x in Funs.DB.Sys_User + 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.QualityAudit_PersonQuality on x.UserId equals y.UserId + join z in Funs.DB.Base_Certificate on y.CertificateId equals z.CertificateId + where z.IsRegisterHSSE == true && x.IdentityCard != null && x.IsPost == true + select new Model.OfSafetySupervisorsOutput + { + ProjectId = x.ProjectId, + ProjectName = p.ProjectName, + UnitName = u.UnitName, + Name = x.UserName, + Sex = x.Sex == null ? "" : (x.Sex == "1" ? "男" : "女"), + IdentityCard = x.IdentityCard, + WorkPostName = PostService.GetPostNameById(x.WorkPostId), + Phone = x.Telephone + }).ToList(); + + result.AddRange(query2); + result = result + .GroupBy(x => x.IdentityCard) + .Select(g => g.FirstOrDefault()) + .ToList(); + return result; + } + /// + /// 获取在岗执业注安师(异步) + /// + /// + public static async Task> GetSafetyInjectionEngineerAsync() + { + return await Task.Run(GetSafetyInjectionEngineer); + + } + + /// + /// 获取A证人员 + /// + /// + public static List GetCertificateA() + { + var result = new List(); + var query1 = (from x in Funs.DB.SitePerson_Person + 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.QualityAudit_PersonQuality on x.PersonId equals y.PersonId + join z in Funs.DB.Base_Certificate on y.CertificateId equals z.CertificateId + where BeUnderConstructionList.Contains(p.ProjectId) && z.CertificateType == "A" && x.IsUsed == true && x.IdentityCard != null + 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 = PostService.GetPostNameById(x.WorkPostId), + Phone = x.Telephone + }).ToList(); + var query2 = (from x in Funs.DB.Sys_User + 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.QualityAudit_PersonQuality on x.UserId equals y.UserId + join z in Funs.DB.Base_Certificate on y.CertificateId equals z.CertificateId + where z.CertificateType == "A" && x.IdentityCard != null && x.IsPost == true + select new Model.OfSafetySupervisorsOutput + { + ProjectId = x.ProjectId, + ProjectName = p.ProjectName, + UnitName = u.UnitName, + Name = x.UserName, + Sex = x.Sex == null ? "" : (x.Sex == "1" ? "男" : "女"), + IdentityCard = x.IdentityCard, + WorkPostName = PostService.GetPostNameById(x.WorkPostId), + Phone = x.Telephone + }).ToList(); + query1.AddRange(query2); + result = query1 + .GroupBy(x => x.IdentityCard) + .Select(g => g.FirstOrDefault()) + .ToList(); + return result; + } + /// + /// 获取A证人员(异步) + /// + /// + public static async Task> GetCertificateAAsync() + { + return await Task.Run(GetCertificateA); + } + + /// + /// 获取B证人员 + /// + /// + public static List GetCertificateB() + { + var result = new List(); + var query1 = (from x in Funs.DB.SitePerson_Person + 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.QualityAudit_PersonQuality on x.PersonId equals y.PersonId + join z in Funs.DB.Base_Certificate on y.CertificateId equals z.CertificateId + where BeUnderConstructionList.Contains(p.ProjectId) && z.CertificateType == "B" && x.IsUsed == true && x.IdentityCard != null + 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 = PostService.GetPostNameById(x.WorkPostId), + Phone = x.Telephone + }).ToList(); + var query2 = (from x in Funs.DB.Sys_User + 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.QualityAudit_PersonQuality on x.UserId equals y.UserId + join z in Funs.DB.Base_Certificate on y.CertificateId equals z.CertificateId + where z.CertificateType == "B" && x.IdentityCard != null && x.IsPost == true + select new Model.OfSafetySupervisorsOutput + { + ProjectId = x.ProjectId, + ProjectName = p.ProjectName, + UnitName = u.UnitName, + Name = x.UserName, + Sex = x.Sex == null ? "" : (x.Sex == "1" ? "男" : "女"), + IdentityCard = x.IdentityCard, + WorkPostName = PostService.GetPostNameById(x.WorkPostId), + Phone = x.Telephone + }).ToList(); + query1.AddRange(query2); + result = query1 + .GroupBy(x => x.IdentityCard) + .Select(g => g.FirstOrDefault()) + .ToList(); + return result; + } + /// + /// 获取B证人员(异步) + /// + /// + public static async Task> GetCertificateBAsync() + { + return await Task.Run(GetCertificateB); + + } + + /// + /// 获取C证人员 + /// + /// + public static List GetCertificateC() + { + var result = new List(); + var query1 = (from x in Funs.DB.SitePerson_Person + 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.QualityAudit_PersonQuality on x.PersonId equals y.PersonId + join z in Funs.DB.Base_Certificate on y.CertificateId equals z.CertificateId + where BeUnderConstructionList.Contains(p.ProjectId) && z.CertificateType == "C" && x.IsUsed == true && x.IdentityCard != null + 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 = PostService.GetPostNameById(x.WorkPostId), + Phone = x.Telephone + }).ToList(); + var query2 = (from x in Funs.DB.Sys_User + 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.QualityAudit_PersonQuality on x.UserId equals y.UserId + join z in Funs.DB.Base_Certificate on y.CertificateId equals z.CertificateId + where z.CertificateType == "C" && x.IdentityCard != null && x.IsPost == true + select new Model.OfSafetySupervisorsOutput + { + ProjectId = x.ProjectId, + ProjectName = p.ProjectName, + UnitName = u.UnitName, + Name = x.UserName, + Sex = x.Sex == null ? "" : (x.Sex == "1" ? "男" : "女"), + IdentityCard = x.IdentityCard, + WorkPostName = PostService.GetPostNameById(x.WorkPostId), + Phone = x.Telephone + }).ToList(); + query1.AddRange(query2); + result = query1 + .GroupBy(x => x.IdentityCard) + .Select(g => g.FirstOrDefault()) + .ToList(); return result; } /// - /// 获取企业安委会会议数 + /// 获取C证人员(异步) /// /// - public static int GetSafetyCommitteeMeetingNum() + public static async Task> GetCertificateCAsync() + { + return await Task.Run(GetCertificateC); + } + #endregion + + #region 安全会议数据 + /// + /// 获取企业安委会会数据 + /// + /// + public static List GetSafetyCommitteeMeeting() { var result = - (from x in Funs.DB.Meeting_CompanySafetyMeeting where x.CompileDate > Const.DtmarkTime select x) - .Count(); - return result; + (from x in Funs.DB.Meeting_CompanySafetyMeeting + 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 x.CompileDate > Const.DtmarkTime + select new MeetingOutput() + { + ProjectId = x.ProjectId, + ProjectName = p.ProjectName, + UnitId = x.UnitId, + UnitName = u.UnitName, + Id = x.CompanySafetyMeetingId, + MeetingName = x.CompanySafetyMeetingName, + MeetingDate = x.CompanySafetyMeetingDate, + MeetingHours = x.MeetingHours, + HostMan = x.MeetingHostMan, + AttentPerson = x.AttentPerson, + AttentPersonNum = x.AttentPersonNum, + }); + return result.ToList(); } + /// + /// 获取企业安委会会数据(异步) + /// + /// + public static async Task> GetSafetyCommitteeMeetingAsync() + { + return await Task.Run(GetSafetyCommitteeMeeting); + } + /// /// 获取企业专题会议数 @@ -677,128 +1764,1875 @@ namespace BLL public static int GetEnterpriseTopicsMeetingNum() { var result = (from x in Funs.DB.Meeting_CompanySpecialMeeting - where x.CompileDate > Const.DtmarkTime - select x).Count(); + where x.CompileDate > Const.DtmarkTime + select x).Count(); return result; } + /// + /// 获取企业专题会议 + /// + /// + public static List GetEnterpriseTopicsMeeting() + { + var result = + (from x in Funs.DB.Meeting_CompanySpecialMeeting + join u in Funs.DB.Base_Unit on x.UnitId equals u.UnitId into uGroup + from u in uGroup.DefaultIfEmpty() + where x.CompileDate > Const.DtmarkTime + select new MeetingOutput() + { + + UnitId = x.UnitId, + UnitName = u.UnitName, + Id = x.CompanySpecialMeetingId, + MeetingName = x.CompanySpecialMeetingName, + MeetingDate = x.CompanySpecialMeetingDate, + MeetingHours = x.MeetingHours, + HostMan = x.MeetingHostMan, + AttentPerson = x.AttentPerson, + AttentPersonNum = x.AttentPersonNum, + }); + return result.ToList(); + } + /// + /// 获取企业专题会议(异步) + /// + /// + public static async Task> GetEnterpriseTopicsMeetingAsync() + { + return await Task.Run(GetEnterpriseTopicsMeeting); + } + + /// + /// 获取项目班前会 + /// + /// + public static List GetProjectClassMeeting() + { + var result = + ( + from x in Funs.DB.Meeting_ClassMeeting + join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup + from p in pGroup.DefaultIfEmpty() + where x.CompileDate > Const.DtmarkTime && BeUnderConstructionList.Contains(p.ProjectId) + select new MeetingOutput() + { + ProjectId = x.ProjectId, + ProjectName = p.ProjectName, + Id = x.ClassMeetingId, + MeetingName = x.ClassMeetingName, + MeetingDate = x.ClassMeetingDate, + MeetingHours = x.MeetingHours, + HostMan = x.MeetingHostMan, + AttentPerson = x.AttentPerson, + AttentPersonNum = x.AttentPersonNum, + }); + return result.ToList(); + } + /// + /// 获取项目班前会议(异步) + /// + /// + public static async Task> GetProjectClassMeetingAsync() + { + return await Task.Run(GetProjectClassMeeting); + } + + /// + /// 获取项目专题会议 + /// + /// + public static List GetProjectSpecialMeeting() + { + var result = + ( + from x in Funs.DB.Meeting_SpecialMeeting + join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup + from p in pGroup.DefaultIfEmpty() + where x.CompileDate > Const.DtmarkTime && BeUnderConstructionList.Contains(p.ProjectId) + select new MeetingOutput() + { + ProjectId = x.ProjectId, + ProjectName = p.ProjectName, + Id = x.SpecialMeetingId, + MeetingName = x.SpecialMeetingName, + MeetingDate = x.SpecialMeetingDate, + MeetingHours = x.MeetingHours, + HostMan = x.MeetingHostMan, + AttentPerson = x.AttentPerson, + AttentPersonNum = x.AttentPersonNum, + }); + return result.ToList(); + } + /// + /// 获取项目专题会议(异步) + /// + /// + public static async Task> GetProjectSpecialMeetingAsync() + { + return await Task.Run(GetProjectSpecialMeeting); + } + + /// + /// 获取项目安全领导小组会议 + /// + /// + public static List GetProjectSafetyLeadingGroupMeeting() + { + var result = + ( + from x in Funs.DB.Meeting_SafetyLeaderGroupMeeting + join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup + from p in pGroup.DefaultIfEmpty() + where x.CompileDate > Const.DtmarkTime && BeUnderConstructionList.Contains(p.ProjectId) + select new MeetingOutput() + { + ProjectId = x.ProjectId, + ProjectName = p.ProjectName, + Id = x.SafetyLeaderGroupMeetingId, + MeetingName = x.SafetyLeaderGroupMeetingName, + MeetingDate = x.SafetyLeaderGroupMeetingDate, + MeetingHours = x.MeetingHours, + HostMan = x.MeetingHostMan, + AttentPerson = x.AttentPerson, + AttentPersonNum = x.AttentPersonNum, + }); + return result.ToList(); + } + /// + /// 获取项目安全领导小组会议(异步) + /// + /// + public static async Task> GetProjectSafetyLeadingGroupMeetingAsync() + { + return await Task.Run(GetProjectSafetyLeadingGroupMeeting); + } + /// + /// 获取项目安全例会数 + /// + /// + public static List GetProjectSafetyMeeting() + { + var result = (from x in Funs.DB.Meeting_WeekMeeting + 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 MeetingOutput() + { + ProjectId = x.ProjectId, + ProjectName = p.ProjectName, + Id = x.WeekMeetingId, + MeetingName = x.WeekMeetingName, + MeetingDate = x.WeekMeetingDate, + MeetingHours = x.MeetingHours, + HostMan = x.MeetingHostMan, + AttentPerson = x.AttentPerson, + AttentPersonNum = x.AttentPersonNum, + }).Union + (from x in Funs.DB.Meeting_MonthMeeting + join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup + from p in pGroup.DefaultIfEmpty() + where BeUnderConstructionList.Contains(x.ProjectId) && x.CompileDate > Const.DtmarkTime + select new MeetingOutput() + { + ProjectId = x.ProjectId, + ProjectName = p.ProjectName, + Id = x.MonthMeetingId, + MeetingName = x.MonthMeetingName, + MeetingDate = x.MonthMeetingDate, + MeetingHours = x.MeetingHours, + HostMan = x.MeetingHostMan, + AttentPerson = x.AttentPerson, + AttentPersonNum = x.AttentPersonNum, + }); + return result.ToList(); + + } + /// + /// 获取项目安全例会数(异步) + /// + /// + public static async Task> GetProjectSafetyMeetingAsync() + { + return await Task.Run(GetProjectSafetyMeeting); + + } + + #endregion + + #region 安全监督检查数据 /// /// 获取企业负责人带班检查次数 /// /// - public static int GetCompanyLeadShiftCheckNum(string[] pids=null) + public static List GetCompanyLeadShiftCheck() { - if (pids == null) - { - var result = (from x in Funs.DB.Supervise_SuperviseCheckReport - where x.CheckType == "1" && x.CheckDate > Const.DtmarkTime - select x).Count(); - return result; - } - else { - var result = (from x in Funs.DB.Supervise_SuperviseCheckReport - where x.CheckType == "1" && x.CheckDate > Const.DtmarkTime - && pids.Contains(x.ProjectId) - select x).Count(); - return result; - } - + var result = (from x in Funs.DB.Supervise_SuperviseCheckReport + 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 x.CheckType == "1" && x.CheckDate > Const.DtmarkTime + select new Model.CheckOutput() + { + ProjectId = x.ProjectId, + ProjectName = p.ProjectName, + UnitId = x.UnitId, + UnitName = u.UnitName, + Id = x.SuperviseCheckReportId, + CheckTeam = x.CheckTeam, + CheckDate = x.CheckDate, + }); + return result.ToList(); } + /// + /// 获取企业负责人带班检查次数(异步) + /// + /// + public static async Task> GetCompanyLeadShiftCheckAsync() + { + return await Task.Run(GetCompanyLeadShiftCheck); + } + + /// /// 获取企业综合检查次数 /// /// - public static int GetCompanyComprehensiveCheckNum(string[] pids = null) + public static List GetCompanyComprehensiveCheck() { - if (pids == null) { - var result = (from x in Funs.DB.Supervise_SuperviseCheckReport - where x.CheckType == "2" && x.CheckDate > Const.DtmarkTime - select x).Count(); - return result; - } - else { - var result = (from x in Funs.DB.Supervise_SuperviseCheckReport - where x.CheckType == "2" && x.CheckDate > Const.DtmarkTime - && pids.Contains(x.ProjectId) - select x).Count(); - return result; - } - + var result = (from x in Funs.DB.Supervise_SuperviseCheckReport + 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 x.CheckType == "2" && x.CheckDate > Const.DtmarkTime + select new Model.CheckOutput() + { + ProjectId = x.ProjectId, + ProjectName = p.ProjectName, + UnitId = x.UnitId, + UnitName = u.UnitName, + Id = x.SuperviseCheckReportId, + CheckTeam = x.CheckTeam, + CheckDate = x.CheckDate, + }); + return result.ToList(); + } + /// + /// 获取企业综合检查次数(异步) + /// + /// + public static async Task> GetCompanyComprehensiveCheckAsync() + { + return await Task.Run(GetCompanyComprehensiveCheck); } /// /// 获取企业专项检查次数 /// /// - public static int GetCompanySpecialCheckNum(string[] pids = null) + public static List GetCompanySpecialCheck() { - if (pids == null) - { - var result = (from x in Funs.DB.Supervise_SuperviseCheckReport - where x.CheckType == "3" && x.CheckDate > Const.DtmarkTime - select x).Count(); - return result; - } - else { - var result = (from x in Funs.DB.Supervise_SuperviseCheckReport - where x.CheckType == "3" && x.CheckDate > Const.DtmarkTime - && pids.Contains(x.ProjectId) - select x).Count(); - return result; - } + var result = (from x in Funs.DB.Supervise_SuperviseCheckReport + 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 x.CheckType == "3" && x.CheckDate > Const.DtmarkTime + select new Model.CheckOutput() + { + ProjectId = x.ProjectId, + ProjectName = p.ProjectName, + UnitId = x.UnitId, + UnitName = u.UnitName, + Id = x.SuperviseCheckReportId, + CheckTeam = x.CheckTeam, + CheckDate = x.CheckDate, + }); + return result.ToList(); + } + /// + /// 获取企业专项检查次数(异步) + /// + /// + public static async Task> GetCompanySpecialCheckAsync() + { + return await Task.Run(GetCompanySpecialCheck); + } + /// + /// 获取项目负责人带班检查次数 + /// + /// + public static List GetProjectLeadShiftCheck() + { + var result = (from x in Funs.DB.Check_ProjectLeaderCheck + 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.CheckDate > Const.DtmarkTime + select new Model.CheckOutput() + { + ProjectId = x.ProjectId, + ProjectName = p.ProjectName, + UnitName = UnitService.getUnitNamesUnitIds(x.UnitIds), + Id = x.ProjectLeaderCheckId, + CheckTeam = UserService.getUserNamesUserIds(x.LeaderIds), + CheckDate = x.CheckDate, + }); + return result.ToList(); + } + /// + /// 获取项目负责人带班检查次数(异步) + /// + /// + public static async Task> GetProjectLeadShiftCheckAsync() + { + return await Task.Run(GetProjectLeadShiftCheck); } + /// + /// 获取项目专项检查次数 + /// + /// + public static List GetProjectSpecialCheck() + { + var result = (from x in Funs.DB.Check_CheckSpecial + 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.CheckTime > Const.DtmarkTime + select new Model.CheckOutput() + { + ProjectId = x.ProjectId, + ProjectName = p.ProjectName, + UnitName = UnitService.getUnitNamesUnitIds(x.PartInUnits), + Id = x.CheckSpecialId, + CheckTeam = x.PartInPersonNames, + CheckDate = x.CheckTime, + }); + return result.ToList(); + } + /// + /// 获取项目专项检查次数(异步) + /// + /// + public static async Task> GetProjectSpecialCheckAsync() + { + return await Task.Run(GetProjectSpecialCheck); + } + + /// + /// 获取项目专业检查次数 + /// + /// + public static List GetProjectMajorCheck() + { + var result = (from x in Funs.DB.HSSE_Hazard_HazardRegister + 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.ResponsibleUnit equals u.UnitId into uGroup + from u in uGroup.DefaultIfEmpty() + join user in Funs.DB.Sys_User on x.CheckManId equals user.UserId into userGroup + from user in userGroup.DefaultIfEmpty() + where BeUnderConstructionList.Contains(p.ProjectId) && x.CheckTime > Const.DtmarkTime + select new Model.CheckOutput() + { + ProjectId = x.ProjectId, + ProjectName = p.ProjectName, + UnitId = x.ResponsibleUnit, + UnitName = u.UnitName, + Id = x.HazardRegisterId, + CheckTeam = user.UserName, + CheckDate = x.CheckTime, + }); + return result.ToList(); + } + /// + /// 获取项目专业检查次数(异步) + /// + /// + public static async Task> GetProjectMajorCheckAsync() + { + return await Task.Run(GetProjectMajorCheck); + } + #endregion + + #region 应急管理数据 /// /// 获取企业级综合预案数 /// /// - public static int GetCompanyComprehensivePlanNum() + public static List GetCompanyComprehensivePlan() { var result = (from x in Funs.DB.Emergency_EmergencyList_Unit - join y in Funs.DB.Base_EmergencyType on x.EmergencyTypeId equals y.EmergencyTypeId - where y.EmergencyTypeName.Contains("综合") && x.CompileDate > Const.DtmarkTime - select x).Count(); + join y in Funs.DB.Base_EmergencyType on x.EmergencyTypeId equals y.EmergencyTypeId + where y.EmergencyTypeName.Contains("综合") && x.CompileDate > Const.DtmarkTime + select new Model.EmergencyOutput + { + ProjectId = x.ProjectId, + ProjectName = ProjectService.GetProjectNameByProjectId(x.ProjectId), + UnitId = x.UnitId, + UnitName = UnitService.GetUnitNameByUnitId(x.UnitId), + Id = x.EmergencyListId, + EmergencyName = x.EmergencyName, + EmergencyTypeName = y.EmergencyTypeName, + VersionCode = x.VersionCode, + Date = x.CompileDate, + }).ToList(); return result; } + /// + /// 获取企业级综合预案数(异步) + /// + /// + public static async Task> GetCompanyComprehensivePlanAsync() + { + return await Task.Run(GetCompanyComprehensivePlan); + } /// /// 获取企业级专项预案数 /// /// - public static int GetCompanySpecialPlanNum() + public static List GetCompanySpecialPlan() { var result = (from x in Funs.DB.Emergency_EmergencyList_Unit - join y in Funs.DB.Base_EmergencyType on x.EmergencyTypeId equals y.EmergencyTypeId - where y.EmergencyTypeName.Contains("专项") && x.CompileDate > Const.DtmarkTime - select x).Count(); + join y in Funs.DB.Base_EmergencyType on x.EmergencyTypeId equals y.EmergencyTypeId + where y.EmergencyTypeName.Contains("专项") && x.CompileDate > Const.DtmarkTime + select new Model.EmergencyOutput + { + ProjectId = x.ProjectId, + ProjectName = ProjectService.GetProjectNameByProjectId(x.ProjectId), + UnitId = x.UnitId, + UnitName = UnitService.GetUnitNameByUnitId(x.UnitId), + Id = x.EmergencyListId, + EmergencyName = x.EmergencyName, + EmergencyTypeName = y.EmergencyTypeName, + VersionCode = x.VersionCode, + Date = x.CompileDate, + }).ToList(); return result; } + /// + /// 获取企业级专项预案数(异步) + /// + /// + public static async Task> GetCompanySpecialPlanAsync() + { + return await Task.Run(GetCompanySpecialPlan); + } /// /// 获取企业级现场处置预案 /// /// - public static int GetCompanyOnSiteDisposalPlan() + public static List GetCompanyOnSiteDisposalPlan() { var result = (from x in Funs.DB.Emergency_EmergencyList_Unit - join y in Funs.DB.Base_EmergencyType on x.EmergencyTypeId equals y.EmergencyTypeId - where y.EmergencyTypeName.Contains("现场处置") && x.CompileDate > Const.DtmarkTime - select x).Count(); + join y in Funs.DB.Base_EmergencyType on x.EmergencyTypeId equals y.EmergencyTypeId + where y.EmergencyTypeName.Contains("现场处置") && x.CompileDate > Const.DtmarkTime + select new Model.EmergencyOutput + { + ProjectId = x.ProjectId, + ProjectName = ProjectService.GetProjectNameByProjectId(x.ProjectId), + UnitId = x.UnitId, + UnitName = UnitService.GetUnitNameByUnitId(x.UnitId), + Id = x.EmergencyListId, + EmergencyName = x.EmergencyName, + EmergencyTypeName = y.EmergencyTypeName, + VersionCode = x.VersionCode, + Date = x.CompileDate, + }).ToList(); return result; } + /// + /// 获取企业级现场处置预案(异步) + /// + /// + public static async Task> GetCompanyOnSiteDisposalPlanAsync() + { + return await Task.Run(GetCompanyOnSiteDisposalPlan); + } /// /// 获取企业级演练次数 /// /// - public static int GetCompanyDrillNum() + public static List GetCompanyDrill() { var result = (from x in Funs.DB.Emergency_DrillRecordList_Unit - where x.CompileDate > Const.DtmarkTime - select x).Count(); + join y in Funs.DB.Sys_Const on x.DrillRecordType equals y.ConstValue + where y.GroupId == "DrillRecordType" + where x.CompileDate > Const.DtmarkTime + select new Model.EmergencyOutput + { + ProjectId = x.ProjectId, + ProjectName = ProjectService.GetProjectNameByProjectId(x.ProjectId), + UnitId = x.UnitIds, + UnitName = UnitService.getUnitNamesUnitIds(x.UnitIds), + Id = x.DrillRecordListId, + EmergencyName = x.DrillRecordName, + EmergencyTypeName = y.ConstText, + Date = x.DrillRecordDate, + DrillCost = x.DrillCost, + JointPersonNum = x.JointPersonNum, + }).ToList(); return result; } + /// + /// 获取企业级演练次数(异步) + /// + /// + public static async Task> GetCompanyDrillAsync() + { + return await Task.Run(GetCompanyDrill); + } + + /// + /// 获取项目级综合预案 + /// + /// + public static List GetProjectComprehensivePlan() + { + var result = (from x in Funs.DB.Emergency_EmergencyList + join y in Funs.DB.Base_EmergencyType on x.EmergencyTypeId equals y.EmergencyTypeId + where BeUnderConstructionList.Contains(x.ProjectId) && y.EmergencyTypeName.Contains("综合") && + x.CompileDate > Const.DtmarkTime + select new Model.EmergencyOutput + { + ProjectId = x.ProjectId, + ProjectName = ProjectService.GetProjectNameByProjectId(x.ProjectId), + UnitId = x.UnitId, + UnitName = UnitService.GetUnitNameByUnitId(x.UnitId), + Id = x.EmergencyListId, + EmergencyName = x.EmergencyName, + EmergencyTypeName = y.EmergencyTypeName, + VersionCode = x.VersionCode, + Date = x.CompileDate, + }).ToList(); + return result; + } + /// + /// 获取项目级综合预案(异步) + /// + /// + public static async Task> GetProjectComprehensivePlanAsync() + { + return await Task.Run(GetProjectComprehensivePlan); + } + + /// + /// 获取项目级专项预案数 + /// + /// + public static List GetProjectSpecialPlan() + { + var result = (from x in Funs.DB.Emergency_EmergencyList + join y in Funs.DB.Base_EmergencyType on x.EmergencyTypeId equals y.EmergencyTypeId + where BeUnderConstructionList.Contains(x.ProjectId) && y.EmergencyTypeName.Contains("专项") && + x.CompileDate > Const.DtmarkTime + select new Model.EmergencyOutput + { + ProjectId = x.ProjectId, + ProjectName = ProjectService.GetProjectNameByProjectId(x.ProjectId), + UnitId = x.UnitId, + UnitName = UnitService.GetUnitNameByUnitId(x.UnitId), + Id = x.EmergencyListId, + EmergencyName = x.EmergencyName, + EmergencyTypeName = y.EmergencyTypeName, + VersionCode = x.VersionCode, + Date = x.CompileDate, + }).ToList(); + return result; + } + /// + /// 获取项目级专项预案数(异步) + /// + /// + public static async Task> GetProjectSpecialPlanAsync() + { + return await Task.Run(GetProjectSpecialPlan); + } + + /// + /// 获取项目级现场处置预案 + /// + /// + public static List GetProjectOnSiteDisposalPlan() + { + var result = (from x in Funs.DB.Emergency_EmergencyList + join y in Funs.DB.Base_EmergencyType on x.EmergencyTypeId equals y.EmergencyTypeId + where BeUnderConstructionList.Contains(x.ProjectId) && y.EmergencyTypeName.Contains("现场处置") && + x.CompileDate > Const.DtmarkTime + select new Model.EmergencyOutput + { + ProjectId = x.ProjectId, + ProjectName = ProjectService.GetProjectNameByProjectId(x.ProjectId), + UnitId = x.UnitId, + UnitName = UnitService.GetUnitNameByUnitId(x.UnitId), + Id = x.EmergencyListId, + EmergencyName = x.EmergencyName, + EmergencyTypeName = y.EmergencyTypeName, + VersionCode = x.VersionCode, + Date = x.CompileDate, + }).ToList(); + return result; + } + /// + /// 获取项目级现场处置预案(异步) + /// + /// + public static async Task> GetProjectOnSiteDisposalPlanAsync() + { + return await Task.Run(GetProjectOnSiteDisposalPlan); + } + + /// + /// 获取项目级演练次数 + /// + /// + public static List GetProjectDrill() + { + var result = (from x in Funs.DB.Emergency_DrillRecordList + join y in Funs.DB.Sys_Const on x.DrillRecordType equals y.ConstValue + where y.GroupId == "DrillRecordType" + where BeUnderConstructionList.Contains(x.ProjectId) && x.CompileDate > Const.DtmarkTime + select new Model.EmergencyOutput + { + ProjectId = x.ProjectId, + ProjectName = ProjectService.GetProjectNameByProjectId(x.ProjectId), + UnitId = x.UnitIds, + UnitName = UnitService.getUnitNamesUnitIds(x.UnitIds), + Id = x.DrillRecordListId, + EmergencyName = x.DrillRecordName, + EmergencyTypeName = y.ConstText, + Date = x.DrillRecordDate, + DrillCost = x.DrillCost, + JointPersonNum = x.JointPersonNum, + }).ToList(); + return result; + } + /// + /// 获取项目级演练次数(异步) + /// + /// + public static async Task> GetProjectDrillAsync() + { + return await Task.Run(GetProjectDrill); + } + #endregion + + #region 基础信息 + /// + /// 获取在建项目数 + /// + /// + public static List GetBeUnderConstruction() + { + var projectInfos = from project in Funs.DB.Base_Project + join unit in Funs.DB.Base_Unit on project.UnitId equals unit.UnitId into unitJoin + from unit in unitJoin.DefaultIfEmpty() + join projectType in Funs.DB.Base_ProjectType on project.ProjectType equals projectType.ProjectTypeId into projectTypeJoin + from projectType in projectTypeJoin.DefaultIfEmpty() + join sysConst in Funs.DB.Sys_Const on new { ProjectState2 = project.ProjectState2, GroupId = BLL.ConstValue.GroupId_ProjectState } equals new { ProjectState2 = sysConst.ConstValue, GroupId = sysConst.GroupId } into sysConstJoin + from sysConst in sysConstJoin.DefaultIfEmpty() + where (project.ProjectAttribute == "GONGCHENG" || project.ProjectAttribute == null) && (project.IsDelete == null || project.IsDelete == false) && project.ProjectState == "1" + select new ProjectOutput + { + ProjectId = project.ProjectId, + ProjectCode = project.ProjectCode, + ProjectName = project.ProjectName, + UnitId = project.UnitId, + UnitName = unit.UnitName, + StartDate = project.StartDate, + EndDate = project.EndDate, + ProjectAddress = project.ProjectAddress, + ShortName = project.ShortName, + ConstructionMoney = project.ConstructionMoney, + ProjectStateName = project.ProjectState == BLL.Const.ProjectState_2 ? "暂停中" : (project.ProjectState == BLL.Const.ProjectState_3 ? "已完工" : "施工中"), + ProjectState = project.ProjectState, + ProjectAttributeName = project.ProjectAttribute == "GONGCHENG" ? "工程" : (project.ProjectAttribute == "SHIYE" ? "实业" : ""), + ProjectMoney = project.ProjectMoney, + DayCount = DateTime.Now.Subtract(project.StartDate.Value).Days, + ProjectTypeName = projectType.ProjectTypeName, + ProjectStateName2 = sysConst.ConstText + }; + var result = projectInfos.ToList(); + return result; + } + /// + /// 获取在建项目数(异步) + /// + /// + public static async Task> GetBeUnderConstructionAsync() + { + return await Task.Run(GetBeUnderConstruction); + } + + + /// + /// 获取停工项目数 + /// + /// + public static List GetShutdown() + { + var projectInfos = from project in Funs.DB.Base_Project + join unit in Funs.DB.Base_Unit on project.UnitId equals unit.UnitId into unitJoin + from unit in unitJoin.DefaultIfEmpty() + join projectType in Funs.DB.Base_ProjectType on project.ProjectType equals projectType.ProjectTypeId into projectTypeJoin + from projectType in projectTypeJoin.DefaultIfEmpty() + join sysConst in Funs.DB.Sys_Const on new { ProjectState2 = project.ProjectState2, GroupId = BLL.ConstValue.GroupId_ProjectState } equals new { ProjectState2 = sysConst.ConstValue, GroupId = sysConst.GroupId } into sysConstJoin + from sysConst in sysConstJoin.DefaultIfEmpty() + where (project.ProjectAttribute == "GONGCHENG" || project.ProjectAttribute == null) && (project.IsDelete == null || project.IsDelete == false) && project.ProjectState == "2" + select new ProjectOutput + { + ProjectId = project.ProjectId, + ProjectCode = project.ProjectCode, + ProjectName = project.ProjectName, + UnitId = project.UnitId, + UnitName = unit.UnitName, + StartDate = project.StartDate, + EndDate = project.EndDate, + ProjectAddress = project.ProjectAddress, + ShortName = project.ShortName, + ConstructionMoney = project.ConstructionMoney, + ProjectStateName = project.ProjectState == BLL.Const.ProjectState_2 ? "暂停中" : (project.ProjectState == BLL.Const.ProjectState_3 ? "已完工" : "施工中"), + ProjectState = project.ProjectState, + ProjectAttributeName = project.ProjectAttribute == "GONGCHENG" ? "工程" : (project.ProjectAttribute == "SHIYE" ? "实业" : ""), + ProjectMoney = project.ProjectMoney, + DayCount = DateTime.Now.Subtract(project.StartDate.Value).Days, + ProjectTypeName = projectType.ProjectTypeName, + ProjectStateName2 = sysConst.ConstText + }; + var result = projectInfos.ToList(); + return result; + } + /// + /// 获取停工项目数(异步) + /// + /// + public static async Task> GetShutdownAsync() + { + return await Task.Run(GetShutdown); + } + /// + /// 获取完工项目数 + /// + /// + public static List GetCompletedProject() + { + var projectInfos = from project in Funs.DB.Base_Project + join unit in Funs.DB.Base_Unit on project.UnitId equals unit.UnitId into unitJoin + from unit in unitJoin.DefaultIfEmpty() + join projectType in Funs.DB.Base_ProjectType on project.ProjectType equals projectType.ProjectTypeId into projectTypeJoin + from projectType in projectTypeJoin.DefaultIfEmpty() + join sysConst in Funs.DB.Sys_Const on new { ProjectState2 = project.ProjectState2, GroupId = BLL.ConstValue.GroupId_ProjectState } equals new { ProjectState2 = sysConst.ConstValue, GroupId = sysConst.GroupId } into sysConstJoin + from sysConst in sysConstJoin.DefaultIfEmpty() + where (project.ProjectAttribute == "GONGCHENG" || project.ProjectAttribute == null) && (project.IsDelete == null || project.IsDelete == false) && project.ProjectState == "3" + select new ProjectOutput + { + ProjectId = project.ProjectId, + ProjectCode = project.ProjectCode, + ProjectName = project.ProjectName, + UnitId = project.UnitId, + UnitName = unit.UnitName, + StartDate = project.StartDate, + EndDate = project.EndDate, + ProjectAddress = project.ProjectAddress, + ShortName = project.ShortName, + ConstructionMoney = project.ConstructionMoney, + ProjectStateName = project.ProjectState == BLL.Const.ProjectState_2 ? "暂停中" : (project.ProjectState == BLL.Const.ProjectState_3 ? "已完工" : "施工中"), + ProjectState = project.ProjectState, + ProjectAttributeName = project.ProjectAttribute == "GONGCHENG" ? "工程" : (project.ProjectAttribute == "SHIYE" ? "实业" : ""), + ProjectMoney = project.ProjectMoney, + DayCount = DateTime.Now.Subtract(project.StartDate.Value).Days, + ProjectTypeName = projectType.ProjectTypeName, + ProjectStateName2 = sysConst.ConstText + }; + var result = projectInfos.ToList(); + return result; + } + /// + /// 获取所有项目数 + /// + /// + public static List GetALLProject() + { + var projectInfos = from project in Funs.DB.Base_Project + join unit in Funs.DB.Base_Unit on project.UnitId equals unit.UnitId into unitJoin + from unit in unitJoin.DefaultIfEmpty() + join projectType in Funs.DB.Base_ProjectType on project.ProjectType equals projectType.ProjectTypeId into projectTypeJoin + from projectType in projectTypeJoin.DefaultIfEmpty() + join sysConst in Funs.DB.Sys_Const on new { ProjectState2 = project.ProjectState2, GroupId = BLL.ConstValue.GroupId_ProjectState } equals new { ProjectState2 = sysConst.ConstValue, GroupId = sysConst.GroupId } into sysConstJoin + from sysConst in sysConstJoin.DefaultIfEmpty() + where (project.ProjectAttribute == "GONGCHENG" || project.ProjectAttribute == null) && (project.IsDelete == null || project.IsDelete == false) + select new ProjectOutput + { + ProjectId = project.ProjectId, + ProjectCode = project.ProjectCode, + ProjectName = project.ProjectName, + UnitId = project.UnitId, + UnitName = unit.UnitName, + StartDate = project.StartDate, + EndDate = project.EndDate, + ProjectAddress = project.ProjectAddress, + ShortName = project.ShortName, + ConstructionMoney = project.ConstructionMoney, + ProjectStateName = project.ProjectState == BLL.Const.ProjectState_2 ? "暂停中" : (project.ProjectState == BLL.Const.ProjectState_3 ? "已完工" : "施工中"), + ProjectState = project.ProjectState, + ProjectAttributeName = project.ProjectAttribute == "GONGCHENG" ? "工程" : (project.ProjectAttribute == "SHIYE" ? "实业" : ""), + ProjectMoney = project.ProjectMoney, + DayCount = DateTime.Now.Subtract(project.StartDate.Value).Days, + ProjectTypeName = projectType.ProjectTypeName, + ProjectStateName2 = sysConst.ConstText + }; + var result = projectInfos.ToList(); + return result; + } + + /// + /// 获取参建人数 + /// + /// + public static List GetJoinConstructionPerson() + { + var result = (from x in Funs.DB.SitePerson_Person + where BeUnderConstructionList.Contains(x.ProjectId) && x.IsUsed == true + select new Model.BaseEntities + { + Id = x.PersonId, + ProjectId = x.ProjectId, + UnitId = x.UnitId + }).ToList(); + return result; + } + /// + /// 获取参建人数(异步) + /// + /// + public static async Task> GetJoinConstructionPersonAsync() + { + return await Task.Run(GetJoinConstructionPerson); + } + + + /// + /// 获取在施危大工程数 + /// + /// + public static List GetMajorProjectsUnderConstruction() + { + var result = (from x in Funs.DB.Solution_LargerHazard + where BeUnderConstructionList.Contains(x.ProjectId) && x.States == "2" && + x.RecordTime > Const.DtmarkTime + select new Model.BaseEntities + { + Id = x.HazardId, + ProjectId = x.ProjectId, + }).ToList(); + return result; + } + /// + /// 获取在施危大工程数(异步) + /// + /// + public static async Task> GetMajorProjectsUnderConstructionAsync() + { + return await Task.Run(GetMajorProjectsUnderConstruction); + } + + #endregion + + #region 工时数据 + /// + /// 获取总工时数 + /// + /// + public static int GetTotalWorkingHour() + { + + var thisUnitid = CommonService.GetThisUnitId(); + var yearSumItems = (from x in Funs.DB.Information_MillionsMonthlyReportItem + join y in Funs.DB.Information_MillionsMonthlyReport + on x.MillionsMonthlyReportId equals y.MillionsMonthlyReportId + where y.UnitId == thisUnitid && y.Year == DateTime.Now.Year && y.Month <= DateTime.Now.Month + && x.Affiliation == "本月合计" + select x).Distinct().ToList(); + var result = Convert.ToInt32(yearSumItems.Sum(x => x.TotalWorkNum ?? 0)); + return result; + /*var result = (from x in Funs.DB.SitePerson_DayReportDetail + join y in Funs.DB.SitePerson_DayReport on x.DayReportId equals y.DayReportId + where BeUnderConstructionList.Contains(y.ProjectId) && y.CompileDate > Const.DtmarkTime + select x.PersonWorkTime ?? 0).ToList().Sum(); + var q = Funs.GetNewIntOrZero(result.ToString().Split('.')[0]); + */ + + } + /// + /// 获取总工时数(异步) + /// + /// + public static async Task GetTotalWorkingHourAsync() + { + return await Task.Run(GetTotalWorkingHour); + + } + + /// + /// 获取损失工时数 + /// + /// + public static int GetLostWorkingHour() + { + //var result = + // (from x in Funs.DB.Accident_AccidentHandle + // where BeUnderConstructionList.Contains(x.ProjectId) && x.CompileDate > Const.DtmarkTime + // select x.WorkHoursLoss) + // .ToList().Sum(x => x.Value) + // + (from x in Funs.DB.Accident_AccidentReport + // where BeUnderConstructionList.Contains(x.ProjectId) && x.CompileDate > Const.DtmarkTime + // select x.WorkingHoursLoss) + // .ToList().Sum(x => x.Value); + //var q = Funs.GetNewIntOrZero(result.ToString().Split('.')[0]); + var q = 0; + return q; + } + /// + /// 获取损失工时数(异步) + /// + /// + public static async Task GetLostWorkingHourAsync() + { + return await Task.Run(GetLostWorkingHour); + } + + /// + /// 获取安全工时数 + /// + /// + public static int GetSafeWorkingHour() + { + /*var result1 = (from x in Funs.DB.SitePerson_DayReportDetail + join y in Funs.DB.SitePerson_DayReport on x.DayReportId equals y.DayReportId + where BeUnderConstructionList.Contains(y.ProjectId) && y.CompileDate > Const.DtmarkTime + select x.PersonWorkTime ?? 0).ToList().Sum(); + var result2 = + (from x in Funs.DB.Accident_AccidentHandle + where BeUnderConstructionList.Contains(x.ProjectId) && x.CompileDate > Const.DtmarkTime + select x.WorkHoursLoss) + .ToList().Sum(x => x.Value) + + (from x in Funs.DB.Accident_AccidentReport + where BeUnderConstructionList.Contains(x.ProjectId) && x.CompileDate > Const.DtmarkTime + select x.WorkingHoursLoss) + .ToList().Sum(x => x.Value); + var result = result1 - result2; + var q = Funs.GetNewIntOrZero(result.ToString().Split('.')[0]); + + return q;*/ + var thisUnitid = CommonService.GetThisUnitId(); + var yearSumItems = (from x in Funs.DB.Information_MillionsMonthlyReportItem + join y in Funs.DB.Information_MillionsMonthlyReport + on x.MillionsMonthlyReportId equals y.MillionsMonthlyReportId + where y.UnitId == thisUnitid && y.Year == DateTime.Now.Year && y.Month <= DateTime.Now.Month + && x.Affiliation == "本月合计" + select x).Distinct().ToList(); + var result = Convert.ToInt32(yearSumItems.Sum(x => x.TotalWorkNum ?? 0)); + return result; + } + /// + /// 获取安全工时数(异步) + /// + /// + public static async Task GetSafeWorkingHourAsync() + { + return await Task.Run(GetSafeWorkingHour); + } + + #endregion + + #region 安全教育培训 + + /// + /// 获取三级安全教育培训数 + /// + /// + public static List GetSafeTrain() + { + var result = (from x in Funs.DB.EduTrain_TrainRecord + join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup + from p in pGroup.DefaultIfEmpty() + join y in Funs.DB.Base_TrainType on x.TrainTypeId equals y.TrainTypeId + where BeUnderConstructionList.Contains(p.ProjectId) && y.TrainType == "1" && + x.TrainStartDate > Const.DtmarkTime + select new Model.EduTrainOutput() + { + + ProjectId = x.ProjectId, + ProjectName = p.ProjectName, + UnitName = UnitService.getUnitNamesUnitIds(x.UnitIds), + Id = x.TrainingId, + TrainTitle = x.TrainTitle, + TrainStartDate = x.TrainStartDate, + TrainEndDate = x.TrainEndDate, + TrainPersonNum = x.TrainPersonNum ?? 0, + }).ToList(); + return result; + } + /// + /// 获取三级安全教育培训数(异步) + /// + /// + public static async Task> GetSafeTrainAsync() + { + return await Task.Run(GetSafeTrain); + } + + /// + /// 获取专项培训数 + /// + /// + public static List GetSpecialTrain() + { + var result = (from x in Funs.DB.EduTrain_TrainRecord + join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup + from p in pGroup.DefaultIfEmpty() + join y in Funs.DB.Base_TrainType on x.TrainTypeId equals y.TrainTypeId + where BeUnderConstructionList.Contains(p.ProjectId) && y.TrainType == "2" && + x.TrainStartDate > Const.DtmarkTime + select new Model.EduTrainOutput() + { + + ProjectId = x.ProjectId, + ProjectName = p.ProjectName, + UnitName = UnitService.getUnitNamesUnitIds(x.UnitIds), + Id = x.TrainingId, + TrainTitle = x.TrainTitle, + TrainStartDate = x.TrainStartDate, + TrainEndDate = x.TrainEndDate, + TrainPersonNum = x.TrainPersonNum ?? 0, + }).ToList(); + return result; + } + /// + /// 获取专项培训数(异步) + /// + /// + public static async Task> GetSpecialTrainAsync() + { + return await Task.Run(GetSpecialTrain); + } + + /// + /// 获取特种作业培训数 + /// + /// + public static List GetSpecialOperationTrain() + { + var result = (from x in Funs.DB.EduTrain_TrainRecord + join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup + from p in pGroup.DefaultIfEmpty() + join y in Funs.DB.Base_TrainType on x.TrainTypeId equals y.TrainTypeId + where BeUnderConstructionList.Contains(p.ProjectId) && y.TrainType == "3" && + x.TrainStartDate > Const.DtmarkTime + select new Model.EduTrainOutput() + { + + ProjectId = x.ProjectId, + ProjectName = p.ProjectName, + UnitName = UnitService.getUnitNamesUnitIds(x.UnitIds), + Id = x.TrainingId, + TrainTitle = x.TrainTitle, + TrainStartDate = x.TrainStartDate, + TrainEndDate = x.TrainEndDate, + TrainPersonNum = x.TrainPersonNum ?? 0, + }).ToList(); + return result; + } + + public static async Task> GetSpecialOperationTrainAsync() + { + return await Task.Run(GetSpecialOperationTrain); + } + + #endregion + + + + /// + /// 获取能耗总量 + /// + /// + public static int GetTotalEnergyConsumption() + { + var result = 0; + return result; + } + + /// + /// 获取万元营业收入综合能耗 + /// + /// + public static int GetIncomeComprehensiveEnergyConsumption() + { + var result = 0; + return result; + } + + /// + /// 获取二氧化碳 + /// + /// + public static int GetNewWaterConsumption() + { + var result = 0; + return result; + } + + + #region 事故事件数据 + + /// + /// 获取未遂事件数 + /// + /// + public static List GetNearMiss() + { + var result = (from Record in Funs.DB.Accident_AccidentPersonRecord + join AccidentType in Funs.DB.Base_AccidentType on Record.AccidentTypeId equals AccidentType.AccidentTypeId into AccidentTypeGroup + from AccidentType in AccidentTypeGroup.DefaultIfEmpty() + join Project in Funs.DB.Base_Project on Record.ProjectId equals Project.ProjectId into ProjectGroup + from Project in ProjectGroup.DefaultIfEmpty() + join Person in Funs.DB.SitePerson_Person on Record.PersonId equals Person.PersonId into PersonGroup + from Person in PersonGroup.DefaultIfEmpty() + join Unit in Funs.DB.Base_Unit on Person.UnitId equals Unit.UnitId into UnitGroup + from Unit in UnitGroup.DefaultIfEmpty() + where BeUnderConstructionList.Contains(Record.ProjectId) && Record.IsAttempt == "1" && Record.AccidentDate > Const.DtmarkTime + select new AccidentOutput + { + Id = Record.AccidentPersonRecordId, + ProjectId = Record.ProjectId, + ProjectCode = Project.ProjectCode, + ProjectName = Project.ProjectName, + AccidentTypeName = AccidentType.AccidentTypeName, + AccidentDate = Record.AccidentDate, + UnitId = Unit.UnitId, + UnitName = Unit.UnitName, + PeopleNum = 1, + Info = Record.Injury == "1" ? "死亡" : (Record.Injury == "2" ? "重伤" : "轻伤") + }).ToList(); + return result; + } + + public static async Task> GetNearMissAsync() + { + return await Task.Run(GetNearMiss); + } + + /// + /// 获取可记录事件数 + /// + /// + public static List GetRecordableEvent() + { + var result = (from Record in Funs.DB.Accident_AccidentPersonRecord + join AccidentType in Funs.DB.Base_AccidentType on Record.AccidentTypeId equals AccidentType.AccidentTypeId into AccidentTypeGroup + from AccidentType in AccidentTypeGroup.DefaultIfEmpty() + join Project in Funs.DB.Base_Project on Record.ProjectId equals Project.ProjectId into ProjectGroup + from Project in ProjectGroup.DefaultIfEmpty() + join Person in Funs.DB.SitePerson_Person on Record.PersonId equals Person.PersonId into PersonGroup + from Person in PersonGroup.DefaultIfEmpty() + join Unit in Funs.DB.Base_Unit on Person.UnitId equals Unit.UnitId into UnitGroup + from Unit in UnitGroup.DefaultIfEmpty() + where BeUnderConstructionList.Contains(Record.ProjectId) && Record.AccidentDate > Const.DtmarkTime + select new AccidentOutput + { + Id = Record.AccidentPersonRecordId, + ProjectId = Record.ProjectId, + ProjectCode = Project.ProjectCode, + ProjectName = Project.ProjectName, + AccidentTypeName = AccidentType.AccidentTypeName, + AccidentDate = Record.AccidentDate, + UnitId = Unit.UnitId, + UnitName = Unit.UnitName, + PeopleNum = 1, + Info = Record.Injury == "1" ? "死亡" : (Record.Injury == "2" ? "重伤" : "轻伤") + }).ToList(); + return result; + } + + public static async Task> GetRecordableEventAsync() + { + return await Task.Run(GetRecordableEvent); + } + + /// + /// 获取一般事故数 + /// + /// + public static List GetGeneralAccident() + { + var query = from Record in Funs.DB.Accident_AccidentReport + join AccidentType in Funs.DB.Sys_Const on new { ConstValue = Record.AccidentTypeId, GroupId = "AccidentReportRegistration" } equals new { ConstValue = AccidentType.ConstValue, GroupId = AccidentType.GroupId } into AccidentTypeGroup + from AccidentType in AccidentTypeGroup.DefaultIfEmpty() + join Project in Funs.DB.Base_Project on Record.ProjectId equals Project.ProjectId into ProjectGroup + from Project in ProjectGroup.DefaultIfEmpty() + join Unit in Funs.DB.Base_Unit on Record.UnitId equals Unit.UnitId into UnitGroup + from Unit in UnitGroup.DefaultIfEmpty() + where Record.AccidentDate > Const.DtmarkTime && BeUnderConstructionList.Contains(Record.ProjectId) && Record.AccidentDegree == "1" + select new AccidentOutput + { + Id = Record.AccidentReportId, + ProjectId = Record.ProjectId, + ProjectCode = Project.ProjectCode, + ProjectName = Project.ProjectName, + AccidentTypeName = AccidentType.ConstText, + AccidentDate = Record.AccidentDate, + UnitId = Unit.UnitId, + UnitName = Unit.UnitName, + PeopleNum = Record.PeopleNum, + Info = Record.Abstract + }; + + var result = query.ToList(); + + + return result; + } + + public static async Task> GetGeneralAccidentAsync() + { + return await Task.Run(GetGeneralAccident); + } + + /// + /// 获取较大事故数 + /// + /// + public static List GetMajorAccident() + { + var query = from Record in Funs.DB.Accident_AccidentReport + join AccidentType in Funs.DB.Sys_Const on new { ConstValue = Record.AccidentTypeId, GroupId = "AccidentReportRegistration" } equals new { ConstValue = AccidentType.ConstValue, GroupId = AccidentType.GroupId } into AccidentTypeGroup + from AccidentType in AccidentTypeGroup.DefaultIfEmpty() + join Project in Funs.DB.Base_Project on Record.ProjectId equals Project.ProjectId into ProjectGroup + from Project in ProjectGroup.DefaultIfEmpty() + join Unit in Funs.DB.Base_Unit on Record.UnitId equals Unit.UnitId into UnitGroup + from Unit in UnitGroup.DefaultIfEmpty() + where Record.AccidentDate > Const.DtmarkTime && BeUnderConstructionList.Contains(Record.ProjectId) && Record.AccidentDegree == "2" + select new AccidentOutput + { + Id = Record.AccidentReportId, + ProjectId = Record.ProjectId, + ProjectCode = Project.ProjectCode, + ProjectName = Project.ProjectName, + AccidentTypeName = AccidentType.ConstText, + AccidentDate = Record.AccidentDate, + UnitId = Unit.UnitId, + UnitName = Unit.UnitName, + PeopleNum = Record.PeopleNum, + Info = Record.Abstract + }; + + var result = query.ToList(); + return result; + } + + public static async Task> GetMajorAccidentAsync() + { + return await Task.Run(GetMajorAccident); + } + + /// + /// 获取重大事故数 + /// + /// + public static List GetSeriousAccident() + { + var query = from Record in Funs.DB.Accident_AccidentReport + join AccidentType in Funs.DB.Sys_Const on new { ConstValue = Record.AccidentTypeId, GroupId = "AccidentReportRegistration" } equals new { ConstValue = AccidentType.ConstValue, GroupId = AccidentType.GroupId } into AccidentTypeGroup + from AccidentType in AccidentTypeGroup.DefaultIfEmpty() + join Project in Funs.DB.Base_Project on Record.ProjectId equals Project.ProjectId into ProjectGroup + from Project in ProjectGroup.DefaultIfEmpty() + join Unit in Funs.DB.Base_Unit on Record.UnitId equals Unit.UnitId into UnitGroup + from Unit in UnitGroup.DefaultIfEmpty() + where Record.AccidentDate > Const.DtmarkTime && BeUnderConstructionList.Contains(Record.ProjectId) && Record.AccidentDegree == "3" + select new AccidentOutput + { + Id = Record.AccidentReportId, + ProjectId = Record.ProjectId, + ProjectCode = Project.ProjectCode, + ProjectName = Project.ProjectName, + AccidentTypeName = AccidentType.ConstText, + AccidentDate = Record.AccidentDate, + UnitId = Unit.UnitId, + UnitName = Unit.UnitName, + PeopleNum = Record.PeopleNum, + Info = Record.Abstract + }; + + var result = query.ToList(); + return result; + } + + public static async Task> GetSeriousAccidentAsync() + { + return await Task.Run(GetSeriousAccident); + } + /// + /// 获取特别重大事故数 + /// + /// + public static List GetSpecialSeriousAccident() + { + var query = from Record in Funs.DB.Accident_AccidentReport + join AccidentType in Funs.DB.Sys_Const on new { ConstValue = Record.AccidentTypeId, GroupId = "AccidentReportRegistration" } equals new { ConstValue = AccidentType.ConstValue, GroupId = AccidentType.GroupId } into AccidentTypeGroup + from AccidentType in AccidentTypeGroup.DefaultIfEmpty() + join Project in Funs.DB.Base_Project on Record.ProjectId equals Project.ProjectId into ProjectGroup + from Project in ProjectGroup.DefaultIfEmpty() + join Unit in Funs.DB.Base_Unit on Record.UnitId equals Unit.UnitId into UnitGroup + from Unit in UnitGroup.DefaultIfEmpty() + where Record.AccidentDate > Const.DtmarkTime && BeUnderConstructionList.Contains(Record.ProjectId) && Record.AccidentDegree == "4" + select new AccidentOutput + { + Id = Record.AccidentReportId, + ProjectId = Record.ProjectId, + ProjectCode = Project.ProjectCode, + ProjectName = Project.ProjectName, + AccidentTypeName = AccidentType.ConstText, + AccidentDate = Record.AccidentDate, + UnitId = Unit.UnitId, + UnitName = Unit.UnitName, + PeopleNum = Record.PeopleNum, + Info = Record.Abstract + }; + + var result = query.ToList(); + return result; + } + + public static async Task> GetSpecialSeriousAccidentAsync() + { + return await Task.Run(GetSpecialSeriousAccident); + } + + + #endregion + + #region 安全费用 + + /// + /// 获取费用提取(万元) + /// + /// + public static List GetCostExtract() + { + var query = from cost in Funs.DB.CostGoods_CostSmallDetail + join p in Funs.DB.Base_Project on cost.ProjectId equals p.ProjectId into pGroup + from p in pGroup.DefaultIfEmpty() + join unit in Funs.DB.Base_Unit on cost.UnitId equals unit.UnitId into unitGroup + from unit in unitGroup.DefaultIfEmpty() + where BeUnderConstructionList.Contains(p.ProjectId) + select new CostSmallDetailOutput + { + Id = cost.CostSmallDetailId, + ProjectId = p.ProjectId, + ProjectCode = p.ProjectCode, + ProjectName = p.ProjectName, + UnitId = cost.UnitId, + UnitName = unit.UnitName, + Months = cost.Months, + SUMCost = cost.Extract//Math.Round(sumCost, 2) + }; + return query.ToList(); + } + public static async Task> GetCostExtractAsync() + { + return await Task.Run(GetCostExtract); + } + + /// + /// 获取费用使用(万元) + /// + /// + public static List GetCostUse() + { + var query = from cost in Funs.DB.CostGoods_CostSmallDetail + join p in Funs.DB.Base_Project on cost.ProjectId equals p.ProjectId into pGroup + from p in pGroup.DefaultIfEmpty() + join unit in Funs.DB.Base_Unit on cost.UnitId equals unit.UnitId into unitGroup + from unit in unitGroup.DefaultIfEmpty() + let sumCost = (from item in Funs.DB.CostGoods_CostSmallDetailItem + where item.CostSmallDetailId == cost.CostSmallDetailId + select item.CostMoney).Sum() * 1.0m // 10000 + where BeUnderConstructionList.Contains(p.ProjectId) + select new CostSmallDetailOutput + { + Id = cost.CostSmallDetailId, + ProjectId = p.ProjectId, + ProjectCode = p.ProjectCode, + ProjectName = p.ProjectName, + UnitId = cost.UnitId, + UnitName = unit.UnitName, + Months = cost.Months, + SUMCost = sumCost//Math.Round(sumCost, 2) + }; + /*var result = 0; + var costs = (from x in Funs.DB.CostGoods_CostSmallDetailItem + join y in Funs.DB.CostGoods_CostSmallDetail + on x.CostSmallDetailId equals y.CostSmallDetailId + where BeUnderConstructionList.Contains(y.ProjectId) && y.CompileDate > Const.DtmarkTime + select x.CostMoney ?? 0).ToList().Sum(); + result = Funs.GetNewIntOrZero(costs.ToString().Split('.')[0]);*/ + return query.ToList(); + } + public static async Task> GetCostUseAsync() + { + return await Task.Run(GetCostUse); + } + + #endregion + + #region 施工机具 + + /// + /// 获取施工机具在用数 + /// + /// + public static List GetUseEquipment() + { + var query = (from item in Funs.DB.InApproveManager_EquipmentInItem + join eq in Funs.DB.InApproveManager_EquipmentIn on item.EquipmentInId equals eq.EquipmentInId into eqGroup + from eq in eqGroup.DefaultIfEmpty() + join spe in Funs.DB.Base_SpecialEquipment on item.SpecialEquipmentId equals spe.SpecialEquipmentId into speGroup + from spe in speGroup.DefaultIfEmpty() + join p in Funs.DB.Base_Project on eq.ProjectId equals p.ProjectId into pGroup + from p in pGroup.DefaultIfEmpty() + join unit in Funs.DB.Base_Unit on eq.UnitId equals unit.UnitId into unitGroup + from unit in unitGroup.DefaultIfEmpty() + where BeUnderConstructionList.Contains(eq.ProjectId) + select new ConstructionEquipmentOutput + { + Id = item.EquipmentInItemId, + ProjectId = eq.ProjectId, + //ProjectCode = p.ProjectCode, + ProjectName = p.ProjectName, + //UnitId = eq.UnitId, + UnitName = unit.UnitName, + //SpecialEquipmentId = item.SpecialEquipmentId, + SpecialEquipmentName = spe.SpecialEquipmentName, + SizeModel = item.SizeModel, + OwnerCheck = item.OwnerCheck, + CertificateNum = item.CertificateNum, + IsUsed = item.IsUsed, + CompileDate = eq.CompileDate, + EQType = "特种设备" + }) + .Union( + from item in Funs.DB.InApproveManager_GeneralEquipmentInItem + join eq in Funs.DB.InApproveManager_GeneralEquipmentIn on item.GeneralEquipmentInId equals eq.GeneralEquipmentInId into eqGroup + from eq in eqGroup.DefaultIfEmpty() + join spe in Funs.DB.Base_SpecialEquipment on item.SpecialEquipmentId equals spe.SpecialEquipmentId into speGroup + from spe in speGroup.DefaultIfEmpty() + join p in Funs.DB.Base_Project on eq.ProjectId equals p.ProjectId into pGroup + from p in pGroup.DefaultIfEmpty() + join unit in Funs.DB.Base_Unit on eq.UnitId equals unit.UnitId into unitGroup + from unit in unitGroup.DefaultIfEmpty() + where BeUnderConstructionList.Contains(eq.ProjectId) + select new ConstructionEquipmentOutput + { + Id = item.GeneralEquipmentInItemId, + ProjectId = eq.ProjectId, + // ProjectCode = p.ProjectCode, + ProjectName = p.ProjectName, + // UnitId = eq.UnitId, + UnitName = unit.UnitName, + // SpecialEquipmentId = item.SpecialEquipmentId, + SpecialEquipmentName = spe.SpecialEquipmentName, + SizeModel = item.SizeModel, + OwnerCheck = item.OwnerCheck, + CertificateNum = item.CertificateNum, + IsUsed = item.IsUsed, + CompileDate = eq.CompileDate, + EQType = "一般设备" + } + ); + + return query.ToList(); + } + public static async Task> GetUseEquipmentAsync() + { + return await Task.Run(GetUseEquipment); + } + + + + /// + /// 获取施工机具特种设备数 + /// + /// + public static List GetSpecialEquipment() + { + var query = (from item in Funs.DB.InApproveManager_EquipmentInItem + join eq in Funs.DB.InApproveManager_EquipmentIn on item.EquipmentInId equals eq.EquipmentInId into + eqGroup + from eq in eqGroup.DefaultIfEmpty() + join spe in Funs.DB.Base_SpecialEquipment on item.SpecialEquipmentId equals spe.SpecialEquipmentId into + speGroup + from spe in speGroup.DefaultIfEmpty() + join p in Funs.DB.Base_Project on eq.ProjectId equals p.ProjectId into pGroup + from p in pGroup.DefaultIfEmpty() + join unit in Funs.DB.Base_Unit on eq.UnitId equals unit.UnitId into unitGroup + from unit in unitGroup.DefaultIfEmpty() + where BeUnderConstructionList.Contains(eq.ProjectId) + select new ConstructionEquipmentOutput + { + Id = item.EquipmentInItemId, + ProjectId = eq.ProjectId, + //ProjectCode = p.ProjectCode, + ProjectName = p.ProjectName, + //UnitId = eq.UnitId, + UnitName = unit.UnitName, + //SpecialEquipmentId = item.SpecialEquipmentId, + SpecialEquipmentName = spe.SpecialEquipmentName, + SizeModel = item.SizeModel, + OwnerCheck = item.OwnerCheck, + CertificateNum = item.CertificateNum, + IsUsed = item.IsUsed, + CompileDate = eq.CompileDate, + EQType = "特种设备" + }); + return query.ToList(); + } + public static async Task> GetSpecialEquipmentAsync() + { + return await Task.Run(GetSpecialEquipment); + } + + #endregion + + #region 高风险作业许可 + + + /// + /// 获取作业许可项数 + /// + /// + public static List GetLicenses() + { + var result = (from x in Funs.DB.View_License_LicenseManager + where BeUnderConstructionList.Contains(x.ProjectId) && x.IsHighRisk == true && + x.CompileDate > Const.DtmarkTime + select new Model.LicenseOutput + { + Id = x.LicenseManagerId, + ProjectId = x.ProjectId, + ProjectName = ProjectService.GetProjectNameByProjectId(x.ProjectId), + UnitId = x.UnitId, + UnitName = UnitService.GetUnitNameByUnitId(x.UnitId), + LicenseTypeName = x.LicenseTypeName, + UnitTypeName = x.UnitTypeName, + IsHighRisk = x.IsHighRisk, + WorkAreaName = x.WorkStates, + CompileDate = x.CompileDate, + StartDate = x.StartDate, + EndDate = x.EndDate, + WorkStatesStr = x.WorkStatesStr + }).ToList(); + return result; + } + public static async Task> GetLicensesAsync() + { + + return await Task.Run(GetLicenses); + } + + /// + /// 获取作业许可关闭项数 + /// + /// + public static List GetLicensesClose() + { + var result = (from x in Funs.DB.View_License_LicenseManager + where BeUnderConstructionList.Contains(x.ProjectId) && x.IsHighRisk == true && x.WorkStates == "3" && + x.CompileDate > Const.DtmarkTime + select new Model.LicenseOutput + { + Id = x.LicenseManagerId, + ProjectId = x.ProjectId, + ProjectName = ProjectService.GetProjectNameByProjectId(x.ProjectId), + UnitId = x.UnitId, + UnitName = UnitService.GetUnitNameByUnitId(x.UnitId), + LicenseTypeName = x.LicenseTypeName, + UnitTypeName = x.UnitTypeName, + IsHighRisk = x.IsHighRisk, + WorkAreaName = x.WorkStates, + CompileDate = x.CompileDate, + StartDate = x.StartDate, + EndDate = x.EndDate, + WorkStatesStr = x.WorkStatesStr + }).ToList(); + return result; + } + public static async Task> GetLicensesCloseAsync() + { + return await Task.Run(GetLicensesClose); + } + + #endregion + + #region 隐患整改 + + /// + /// 获取一般隐患数据 + /// + /// + public static List GetGeneralHiddenRectificationOutputs() + { + + var query = (from x in Funs.DB.Base_Project + join y in Funs.DB.HSSE_Hazard_HazardRegister on x.ProjectId equals y.ProjectId into yGroup + from y in yGroup.DefaultIfEmpty() + where BeUnderConstructionList.Contains(x.ProjectId) && y.ProblemTypes == "1" && y.Risk_Level == "一般" && y.CheckTime > Const.DtmarkTime + group y by new { x.ProjectId, x.ProjectName, x.ProjectCode } into gg + select new HiddenRectificationOutput + { + ProjectId = gg.Key.ProjectId, + ProjectName = gg.Key.ProjectName, + ProjectCode = gg.Key.ProjectCode, + ProNum = gg.Count(y => y.States != "4" && y.States != "-1"), + RecNum = gg.Count(y => y.States == "3"), + NoRecNum = gg.Count(y => y.States != "3" && y.States != "-1"), + RecRate = gg.Count(y => y.States != "4" && y.States != "-1") == 0 ? "0" : + Math.Round(Convert.ToDecimal( gg.Count(y => y.States == "3") / + gg.Count(y => y.States != "4" && y.States != "-1") * 100), 2, MidpointRounding.AwayFromZero).ToString() + }).ToList(); + + foreach (var item in query) + { + item.RecRate = Math .Round(Convert.ToDecimal(item.RecRate),2) .ToString(); // 转换为字符串并格式化为两位小数 + } + return query; + } + public static async Task> GetGeneralHiddenRectificationOutputsAsync() + { + return await Task.Run(GetGeneralHiddenRectificationOutputs); + } + + /// + /// 获取重大隐患数据 + /// + /// + public static List GetMajorHiddenRectificationOutputs() + { + var query = (from x in Funs.DB.Base_Project + join y in Funs.DB.HSSE_Hazard_HazardRegister on x.ProjectId equals y.ProjectId into yGroup + from y in yGroup.DefaultIfEmpty() + where BeUnderConstructionList.Contains(x.ProjectId) && y.ProblemTypes == "1" && y.Risk_Level == "重大" && y.CheckTime > Const.DtmarkTime + group y by new { x.ProjectId, x.ProjectName, x.ProjectCode } into gg + select new HiddenRectificationOutput + { + ProjectId = gg.Key.ProjectId, + ProjectName = gg.Key.ProjectName, + ProjectCode = gg.Key.ProjectCode, + ProNum = gg.Count(y => y.States != "4" && y.States != "-1" ), + RecNum = gg.Count(y => y.States == "3" ), + NoRecNum = gg.Count(y => y.States != "3" && y.States != "-1" ), + RecRate = gg.Count(y => y.States != "4" && y.States != "-1" ) == 0 ? "0" : + Math.Round((decimal)gg.Count(y => y.States == "3" ) / + gg.Count(y => y.States != "4" && y.States != "-1" ) * 100, 2, MidpointRounding.AwayFromZero).ToString() + }).ToList(); + foreach (var item in query) + { + item.RecRate = Math.Round(Convert.ToDecimal(item.RecRate), 2).ToString(); // 转换为字符串并格式化为两位小数 + } + return query; + } + public static async Task> GetMajorHiddenRectificationOutputsAsync() + { + return await Task.Run(GetMajorHiddenRectificationOutputs); + } + + #endregion + + #region 风险数据 + /// + /// 获取风险数据 + /// + /// + public static List GetSecurityRiskOutputs() + { + var query = (from x in Funs.DB.Base_Project + join y in Funs.DB.Hazard_HazardSelectedItem on x.ProjectId equals y.ProjectId into yGroup + from y in yGroup.DefaultIfEmpty() + join z in Funs.DB.Base_RiskLevel on y.HazardLevel equals z.RiskLevelId into zGroup + from z in zGroup.DefaultIfEmpty() + where BeUnderConstructionList.Contains(x.ProjectId) && (y.IsStart == true || y.State == "1") + group new { y, z } by new { x.ProjectId, x.ProjectName, x.ProjectCode } into gg + select new SecurityRiskOutput + { + ProjectId = gg.Key.ProjectId, + ProjectName = gg.Key.ProjectName, + ProjectCode = gg.Key.ProjectCode, + LowRiskNum = gg.Sum(g => (g.z.RiskLevel == 1 || g.y.HazardLevel == "1") ? 1 : 0), + GeneralRiskNum = gg.Sum(g => (g.z.RiskLevel == 2 || g.y.HazardLevel == "2") ? 1 : 0), + MediumRiskNum = gg.Sum(g => (g.z.RiskLevel == 3 || g.y.HazardLevel == "3") ? 1 : 0), + HighRiskNum = gg.Sum(g => g.z.RiskLevel == 4 ? 1 : 0), + }).ToList(); + return query; + } + public static async Task> GetSecurityRiskOutputsAsync() + { + return await Task.Run(GetSecurityRiskOutputs); + } + #endregion + + #region 危大工程数据 + /// + /// 获取危大工程数据 + /// + /// + public static List GetLargeEngineeringOutputs() + { + var query = (from x in Funs.DB.Base_Project + join y in Funs.DB.Solution_LargerHazard on x.ProjectId equals y.ProjectId into yGroup + from y in yGroup.DefaultIfEmpty() + where BeUnderConstructionList.Contains(x.ProjectId) && y.RecordTime > Const.DtmarkTime + group y by new { x.ProjectId, x.ProjectName, x.ProjectCode } into gg + select new LargeEngineeringOutput + { + ProjectId = gg.Key.ProjectId, + ProjectName = gg.Key.ProjectName, + ProjectCode = gg.Key.ProjectCode, + CompletedNum = gg.Count(x => x.States == "1" && x.IsSuperLargerHazard == false ), + TrainPersonNum = gg.Where(x => x.IsSuperLargerHazard == false ).Sum(x => x.TrainPersonNum) ?? 0, + ConstructionNum = gg.Count(x => x.States == "2" && x.IsSuperLargerHazard == false ), + FinishedNum = gg.Count(x => x.States == "3" && x.IsSuperLargerHazard == false), + SuperCompletedNum = gg.Count(x => x.States == "1" && x.IsSuperLargerHazard == true), + SuperTrainPersonNum = gg.Where(x => x.IsSuperLargerHazard == true).Sum(x => x.TrainPersonNum) ?? 0, + SuperConstructionNum = gg.Count(x => x.States == "2" && x.IsSuperLargerHazard == true), + SuperFinishedNum = gg.Count(x => x.States == "3" && x.IsSuperLargerHazard == true), + + }).ToList(); + return query; + } + public static async Task> GetLargeEngineeringOutputsAsync() + { + return await Task.Run(GetLargeEngineeringOutputs); + } + + /// + /// 获取危大工程审批完成数 + /// + /// + public static int GetCompletedNum() + { + var result = (from x in Funs.DB.Solution_LargerHazard + where BeUnderConstructionList.Contains(x.ProjectId) && x.States == "1" && + x.IsSuperLargerHazard == false && + x.RecordTime > Const.DtmarkTime + select x).Count(); + return result; + } + + /// + /// 获取危大工程培训人次数 + /// + /// + public static int GetTrainPersonNum() + { + var result = (from x in Funs.DB.Solution_LargerHazard + where BeUnderConstructionList.Contains(x.ProjectId) && x.IsSuperLargerHazard == false && + x.RecordTime > Const.DtmarkTime + select x.TrainPersonNum).ToList().Sum(x => x.Value); + return result; + } + + /// + /// 获取危大工程施工个数 + /// + /// + public static int GetConstructionNum() + { + var result = (from x in Funs.DB.Solution_LargerHazard + where BeUnderConstructionList.Contains(x.ProjectId) && x.States == "2" && + x.IsSuperLargerHazard == false && + x.RecordTime > Const.DtmarkTime + select x).Count(); + return result; + } + + /// + /// 获取危大工程完工个数 + /// + /// + public static int GetFinishedNum() + { + var result = (from x in Funs.DB.Solution_LargerHazard + where BeUnderConstructionList.Contains(x.ProjectId) && x.States == "3" && + x.IsSuperLargerHazard == false && + x.RecordTime > Const.DtmarkTime + select x).Count(); + return result; + } + + /// + /// 获取超危大工程审批完成数 + /// + /// + public static int GetSuperCompletedNum() + { + var result = (from x in Funs.DB.Solution_LargerHazard + where BeUnderConstructionList.Contains(x.ProjectId) && x.States == "1" && + x.IsSuperLargerHazard == true && + x.RecordTime > Const.DtmarkTime + select x).Count(); + return result; + } + + /// + /// 获取超危大工程培训人次数 + /// + /// + public static int GetSuperTrainPersonNum() + { + var result = + (from x in Funs.DB.Solution_LargerHazard + where BeUnderConstructionList.Contains(x.ProjectId) && x.IsSuperLargerHazard == true && + x.RecordTime > Const.DtmarkTime + select x.TrainPersonNum).ToList().Sum(x => x.Value); + return result; + } + + /// + /// 获取超危大工程施工个数 + /// + /// + public static int GetSuperConstructionNum() + { + var result = (from x in Funs.DB.Solution_LargerHazard + where BeUnderConstructionList.Contains(x.ProjectId) && x.States == "2" && + x.IsSuperLargerHazard == true && + x.RecordTime > Const.DtmarkTime + select x).Count(); + return result; + } + + /// + /// 获取超危大工程完工个数 + /// + /// + public static int GetSuperFinishedNum() + { + var result = (from x in Funs.DB.Solution_LargerHazard + where BeUnderConstructionList.Contains(x.ProjectId) && x.States == "3" && + x.IsSuperLargerHazard == true && + x.RecordTime > Const.DtmarkTime + select x).Count(); + return result; + } + + #endregion + #region 获取列表 @@ -833,89 +3667,173 @@ namespace BLL if (Count == 0) return null; // 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.BeUnderConstructionNum, - x.ShutdownNum, - x.JoinConstructionPersonNum, - x.MajorProjectsUnderConstructionNum, - x.TotalWorkingHour, - x.LostWorkingHour, - x.SafeWorkingHour, - x.SafeTrainNum, - x.SpecialTrainNum, - x.SpecialOperationTrainNum, - x.TotalEnergyConsumption, - x.IncomeComprehensiveEnergyConsumption, - x.NewWaterConsumption, - x.HeadOfficeInspectorGeneralNum, - x.HeadOfficeFullTimeNum, - x.BranchInspectorGeneralNum, - x.BranchFullTimeNum, - x.ProjectInspectorGeneralNum, - x.ProjectFullTimeNum, - x.ProjectSafetyMonitorNum, - x.SafetyInjectionEngineer, - x.CertificateANum, - x.CertificateBNum, - x.CertificateCNum, - x.SafetyCommitteeMeetingNum, - x.EnterpriseTopicsMeetingNum, - x.ProjectSafetyLeadingGroupMeetingNum, - x.ProjectSafetyMeetingNum, - x.CompanyLeadShiftCheckNum, - x.CompanyComprehensiveCheckNum, - x.CompanySpecialCheckNum, - x.ProjectLeadShiftCheckNum, - x.ProjectSpecialCheckNum, - x.ProjectMajorCheckNum, - x.NearMissNum, - x.RecordableEventNum, - x.GeneralAccidentNum, - x.MajorAccidentNum, - x.SeriousAccidentNum, - x.SpecialSeriousAccidentNum, - x.CompanyComprehensivePlanNum, - x.CompanySpecialPlanNum, - x.CompanyOnSiteDisposalPlan, - x.CompanyDrillNum, - x.ProjectComprehensivePlanNum, - x.ProjectSpecialPlanNum, - x.ProjectOnSiteDisposalPlan, - x.ProjectDrillNum, - x.CostExtract, - x.CostUse, - x.UseEquipmentNum, - x.SpecialEquipmentNum, - x.LicensesNum, - x.LicensesCloseNum, - x.GeneralClosedNum, - x.GeneralNotClosedNum, - x.MajorClosedNum, - x.MajorNotClosedNum, - x.GeneralRiskNum, - x.LowRiskNum, - x.MediumRiskNum, - x.HighRiskNum, - x.CompletedNum, - x.TrainPersonNum, - x.ConstructionNum, - x.FinishedNum, - x.SuperCompletedNum, - x.SuperTrainPersonNum, - x.SuperConstructionNum, - x.SuperFinishedNum, - x.State, - x.CreateDate, - x.CreateMan - }; + select new + { + x.Id, + x.UnitId, + x.CollCropCode, + x.UnitName, + x.ReportDate, + x.BeUnderConstructionNum, + x.ShutdownNum, + x.JoinConstructionPersonNum, + x.MajorProjectsUnderConstructionNum, + x.TotalWorkingHour, + x.LostWorkingHour, + x.SafeWorkingHour, + x.SafeTrainNum, + x.SpecialTrainNum, + x.SpecialOperationTrainNum, + x.EnvironmentalTrainNum, + x.TotalEnergyConsumption, + x.IncomeComprehensiveEnergyConsumption, + x.NewWaterConsumption, + x.HeadOfficeInspectorGeneralNum, + x.HeadOfficeFullTimeNum, + x.BranchInspectorGeneralNum, + x.BranchFullTimeNum, + x.ProjectInspectorGeneralNum, + x.ProjectFullTimeNum, + x.ProjectSafetyMonitorNum, + x.SafetyInjectionEngineer, + x.CertificateANum, + x.CertificateBNum, + x.CertificateCNum, + x.SafetyCommitteeMeetingNum, + x.EnterpriseTopicsMeetingNum, + x.ProjectSafetyLeadingGroupMeetingNum, + x.ProjectSafetyMeetingNum, + x.CompanyLeadShiftCheckNum, + x.CompanyComprehensiveCheckNum, + x.CompanySpecialCheckNum, + x.ProjectLeadShiftCheckNum, + x.ProjectSpecialCheckNum, + x.ProjectMajorCheckNum, + x.NearMissNum, + x.RecordableEventNum, + x.GeneralAccidentNum, + x.MajorAccidentNum, + x.SeriousAccidentNum, + x.SpecialSeriousAccidentNum, + x.CompanyComprehensivePlanNum, + x.CompanySpecialPlanNum, + x.CompanyOnSiteDisposalPlan, + x.CompanyDrillNum, + x.ProjectComprehensivePlanNum, + x.ProjectSpecialPlanNum, + x.ProjectOnSiteDisposalPlan, + x.ProjectDrillNum, + x.CostExtract, + x.CostUse, + x.UseEquipmentNum, + x.SpecialEquipmentNum, + x.LicensesNum, + x.LicensesCloseNum, + x.GeneralClosedNum, + x.GeneralNotClosedNum, + x.MajorClosedNum, + x.MajorNotClosedNum, + x.GeneralRiskNum, + x.LowRiskNum, + x.MediumRiskNum, + x.HighRiskNum, + x.CompletedNum, + x.TrainPersonNum, + x.ConstructionNum, + x.FinishedNum, + x.SuperCompletedNum, + x.SuperTrainPersonNum, + x.SuperConstructionNum, + x.SuperFinishedNum, + x.State, + x.CreateDate, + x.CreateMan + }; } #endregion 获取列表 + + /// + /// 获取企业安委会会议数 + /// + /// + public static int GetSafetyCommitteeMeetingNum() + { + var result = + (from x in Funs.DB.Meeting_CompanySafetyMeeting where x.CompileDate > Const.DtmarkTime select x) + .Count(); + return result; + } + + /// + /// 获取企业负责人带班检查次数 + /// + /// + public static int GetCompanyLeadShiftCheckNum(string[] pids = null) + { + if (pids == null) + { + var result = (from x in Funs.DB.Supervise_SuperviseCheckReport + where x.CheckType == "1" && x.CheckDate > Const.DtmarkTime + select x).Count(); + return result; + } + else + { + var result = (from x in Funs.DB.Supervise_SuperviseCheckReport + where x.CheckType == "1" && x.CheckDate > Const.DtmarkTime + && pids.Contains(x.ProjectId) + select x).Count(); + return result; + } + + } + + /// + /// 获取企业综合检查次数 + /// + /// + public static int GetCompanyComprehensiveCheckNum(string[] pids = null) + { + if (pids == null) + { + var result = (from x in Funs.DB.Supervise_SuperviseCheckReport + where x.CheckType == "2" && x.CheckDate > Const.DtmarkTime + select x).Count(); + return result; + } + else + { + var result = (from x in Funs.DB.Supervise_SuperviseCheckReport + where x.CheckType == "2" && x.CheckDate > Const.DtmarkTime + && pids.Contains(x.ProjectId) + select x).Count(); + return result; + } + + } + + /// + /// 获取企业专项检查次数 + /// + /// + public static int GetCompanySpecialCheckNum(string[] pids = null) + { + if (pids == null) + { + var result = (from x in Funs.DB.Supervise_SuperviseCheckReport + where x.CheckType == "3" && x.CheckDate > Const.DtmarkTime + select x).Count(); + return result; + } + else + { + var result = (from x in Funs.DB.Supervise_SuperviseCheckReport + where x.CheckType == "3" && x.CheckDate > Const.DtmarkTime + && pids.Contains(x.ProjectId) + select x).Count(); + return result; + } + } } } \ No newline at end of file diff --git a/SGGL/BLL/ZHGL/DataSync/HSSEData_HiddenDangerDetailService.cs b/SGGL/BLL/ZHGL/DataSync/HSSEData_HiddenDangerDetailService.cs index 850bf62b..9677c589 100644 --- a/SGGL/BLL/ZHGL/DataSync/HSSEData_HiddenDangerDetailService.cs +++ b/SGGL/BLL/ZHGL/DataSync/HSSEData_HiddenDangerDetailService.cs @@ -82,62 +82,67 @@ namespace BLL } public static void AddHSSEData_HiddenDangerDetail(Model.HSSEData_HiddenDangerDetail newtable) { - - Model.HSSEData_HiddenDangerDetail table = new Model.HSSEData_HiddenDangerDetail + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { - Id = newtable.Id, - UnitId = newtable.UnitId, - CollCropCode = newtable.CollCropCode, - UnitName = newtable.UnitName, - ReportDate = newtable.ReportDate, - TypeName = newtable.TypeName, - TotalNum = newtable.TotalNum, - NeedRectifyNum = newtable.NeedRectifyNum, - }; - db.HSSEData_HiddenDangerDetail.InsertOnSubmit(table); - db.SubmitChanges(); + Model.HSSEData_HiddenDangerDetail table = new Model.HSSEData_HiddenDangerDetail + { + Id = newtable.Id, + UnitId = newtable.UnitId, + CollCropCode = newtable.CollCropCode, + UnitName = newtable.UnitName, + ReportDate = newtable.ReportDate, + TypeName = newtable.TypeName, + TotalNum = newtable.TotalNum, + NeedRectifyNum = newtable.NeedRectifyNum, + }; + db.HSSEData_HiddenDangerDetail.InsertOnSubmit(table); + db.SubmitChanges(); + } } public static void UpdateHSSEData_HiddenDangerDetail(Model.HSSEData_HiddenDangerDetail newtable) { - - Model.HSSEData_HiddenDangerDetail table = db.HSSEData_HiddenDangerDetail.FirstOrDefault(x => x.Id == newtable.Id); - if (table != null) + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { - table.Id = newtable.Id; - table.UnitId = newtable.UnitId; - table.CollCropCode = newtable.CollCropCode; - table.UnitName = newtable.UnitName; - table.ReportDate = newtable.ReportDate; - table.TypeName = newtable.TypeName; - table.TotalNum = newtable.TotalNum; - table.NeedRectifyNum = newtable.NeedRectifyNum; - db.SubmitChanges(); + Model.HSSEData_HiddenDangerDetail table = db.HSSEData_HiddenDangerDetail.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.TypeName = newtable.TypeName; + table.TotalNum = newtable.TotalNum; + table.NeedRectifyNum = newtable.NeedRectifyNum; + db.SubmitChanges(); + } } - } public static void DeleteHSSEData_HiddenDangerDetailById(string Id) { - - Model.HSSEData_HiddenDangerDetail table = db.HSSEData_HiddenDangerDetail.FirstOrDefault(x => x.Id == Id); - if (table != null) + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { - db.HSSEData_HiddenDangerDetail.DeleteOnSubmit(table); - db.SubmitChanges(); + Model.HSSEData_HiddenDangerDetail table = db.HSSEData_HiddenDangerDetail.FirstOrDefault(x => x.Id == Id); + if (table != null) + { + db.HSSEData_HiddenDangerDetail.DeleteOnSubmit(table); + db.SubmitChanges(); + } } - } public static void DeleteHSSEData_HiddenDangerDetailByDate(DateTime? reportDate) { - - var table = db.HSSEData_HiddenDangerDetail.Where(x => x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0); - if (table != null) + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { - db.HSSEData_HiddenDangerDetail.DeleteAllOnSubmit(table); - db.SubmitChanges(); + var table = db.HSSEData_HiddenDangerDetail.Where(x => x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0); + if (table != null) + { + db.HSSEData_HiddenDangerDetail.DeleteAllOnSubmit(table); + db.SubmitChanges(); + } } - } } diff --git a/SGGL/BLL/ZHGL/DataSync/Hazard_RealTimeDeviceService.cs b/SGGL/BLL/ZHGL/DataSync/Hazard_RealTimeDeviceService.cs index ba6f0cad..50a51306 100644 --- a/SGGL/BLL/ZHGL/DataSync/Hazard_RealTimeDeviceService.cs +++ b/SGGL/BLL/ZHGL/DataSync/Hazard_RealTimeDeviceService.cs @@ -136,124 +136,134 @@ namespace BLL public static void AddHazard_RealTimeDevice(Model.Hazard_RealTimeDevice newtable) { - - Model.Hazard_RealTimeDevice table = new Model.Hazard_RealTimeDevice + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { - ID = newtable.ID, - UnitId = newtable.UnitId, - UnitName = newtable.UnitName, - HazardName = newtable.HazardName, - HazardLevel = newtable.HazardLevel, - DeviceCode = newtable.DeviceCode, - DeviceName = newtable.DeviceName, - DeviceType = newtable.DeviceType, - SphereType = newtable.SphereType, - TemperatureType = newtable.TemperatureType, - DesignTemperantureMax = newtable.DesignTemperantureMax, - DesignTemperantureMin = newtable.DesignTemperantureMin, - PressureType = newtable.PressureType, - DesignPressure = newtable.DesignPressure, - DesignPressureMax = newtable.DesignPressureMax, - Medium = newtable.Medium, - MediumForm = newtable.MediumForm, - MediumLevelMax = newtable.MediumLevelMax, - Reserves = newtable.Reserves, - StandardCode = newtable.StandardCode, - StandardName = newtable.StandardName, - StandardType = newtable.StandardType, - StandardDes = newtable.StandardDes, - MeasurementUnit = newtable.MeasurementUnit, - MeterMax = newtable.MeterMax, - MeterMin = newtable.MeterMin, - ThresholdLow1 = newtable.ThresholdLow1, - ThresholdLow2 = newtable.ThresholdLow2, - ThresholdMax1 = newtable.ThresholdMax1, - ThresholdMax2 = newtable.ThresholdMax2, - BitNum = newtable.BitNum, - DateTime = newtable.DateTime, - ProjectId = newtable.ProjectId, - Value = newtable.Value, - FactoryId = newtable.FactoryId, - ReportDate = newtable.ReportDate, - ReceiveDate = newtable.ReceiveDate, - }; - db.Hazard_RealTimeDevice.InsertOnSubmit(table); - db.SubmitChanges(); + Model.Hazard_RealTimeDevice table = new Model.Hazard_RealTimeDevice + { + ID = newtable.ID, + UnitId = newtable.UnitId, + UnitName = newtable.UnitName, + HazardName = newtable.HazardName, + HazardLevel = newtable.HazardLevel, + DeviceCode = newtable.DeviceCode, + DeviceName = newtable.DeviceName, + DeviceType = newtable.DeviceType, + SphereType = newtable.SphereType, + TemperatureType = newtable.TemperatureType, + DesignTemperantureMax = newtable.DesignTemperantureMax, + DesignTemperantureMin = newtable.DesignTemperantureMin, + PressureType = newtable.PressureType, + DesignPressure = newtable.DesignPressure, + DesignPressureMax = newtable.DesignPressureMax, + Medium = newtable.Medium, + MediumForm = newtable.MediumForm, + MediumLevelMax = newtable.MediumLevelMax, + Reserves = newtable.Reserves, + StandardCode = newtable.StandardCode, + StandardName = newtable.StandardName, + StandardType = newtable.StandardType, + StandardDes = newtable.StandardDes, + MeasurementUnit = newtable.MeasurementUnit, + MeterMax = newtable.MeterMax, + MeterMin = newtable.MeterMin, + ThresholdLow1 = newtable.ThresholdLow1, + ThresholdLow2 = newtable.ThresholdLow2, + ThresholdMax1 = newtable.ThresholdMax1, + ThresholdMax2 = newtable.ThresholdMax2, + BitNum = newtable.BitNum, + DateTime = newtable.DateTime, + ProjectId = newtable.ProjectId, + Value = newtable.Value, + FactoryId = newtable.FactoryId, + ReportDate = newtable.ReportDate, + ReceiveDate = newtable.ReceiveDate, + }; + db.Hazard_RealTimeDevice.InsertOnSubmit(table); + db.SubmitChanges(); + } } public static void AddBulkHazard_RealTimeDevice(List newtables) { - - db.Hazard_RealTimeDevice.InsertAllOnSubmit(newtables); - db.SubmitChanges(); + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) + { + db.Hazard_RealTimeDevice.InsertAllOnSubmit(newtables); + db.SubmitChanges(); + } } public static void UpdateHazard_RealTimeDevice(Model.Hazard_RealTimeDevice newtable) { - - Model.Hazard_RealTimeDevice table = db.Hazard_RealTimeDevice.FirstOrDefault(x => x.ID == newtable.ID); - if (table != null) + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { - table.ID = newtable.ID; - table.UnitId = newtable.UnitId; - table.UnitName = newtable.UnitName; - table.HazardName = newtable.HazardName; - table.HazardLevel = newtable.HazardLevel; - table.DeviceCode = newtable.DeviceCode; - table.DeviceName = newtable.DeviceName; - table.DeviceType = newtable.DeviceType; - table.SphereType = newtable.SphereType; - table.TemperatureType = newtable.TemperatureType; - table.DesignTemperantureMax = newtable.DesignTemperantureMax; - table.DesignTemperantureMin = newtable.DesignTemperantureMin; - table.PressureType = newtable.PressureType; - table.DesignPressure = newtable.DesignPressure; - table.DesignPressureMax = newtable.DesignPressureMax; - table.Medium = newtable.Medium; - table.MediumForm = newtable.MediumForm; - table.MediumLevelMax = newtable.MediumLevelMax; - table.Reserves = newtable.Reserves; - table.StandardCode = newtable.StandardCode; - table.StandardName = newtable.StandardName; - table.StandardType = newtable.StandardType; - table.StandardDes = newtable.StandardDes; - table.MeasurementUnit = newtable.MeasurementUnit; - table.MeterMax = newtable.MeterMax; - table.MeterMin = newtable.MeterMin; - table.ThresholdLow1 = newtable.ThresholdLow1; - table.ThresholdLow2 = newtable.ThresholdLow2; - table.ThresholdMax1 = newtable.ThresholdMax1; - table.ThresholdMax2 = newtable.ThresholdMax2; - table.BitNum = newtable.BitNum; - table.DateTime = newtable.DateTime; - table.ProjectId = newtable.ProjectId; - table.Value = newtable.Value; - table.FactoryId = newtable.FactoryId; - table.ReportDate = newtable.ReportDate; - table.ReceiveDate = newtable.ReceiveDate; - db.SubmitChanges(); + Model.Hazard_RealTimeDevice table = db.Hazard_RealTimeDevice.FirstOrDefault(x => x.ID == newtable.ID); + if (table != null) + { + table.ID = newtable.ID; + table.UnitId = newtable.UnitId; + table.UnitName = newtable.UnitName; + table.HazardName = newtable.HazardName; + table.HazardLevel = newtable.HazardLevel; + table.DeviceCode = newtable.DeviceCode; + table.DeviceName = newtable.DeviceName; + table.DeviceType = newtable.DeviceType; + table.SphereType = newtable.SphereType; + table.TemperatureType = newtable.TemperatureType; + table.DesignTemperantureMax = newtable.DesignTemperantureMax; + table.DesignTemperantureMin = newtable.DesignTemperantureMin; + table.PressureType = newtable.PressureType; + table.DesignPressure = newtable.DesignPressure; + table.DesignPressureMax = newtable.DesignPressureMax; + table.Medium = newtable.Medium; + table.MediumForm = newtable.MediumForm; + table.MediumLevelMax = newtable.MediumLevelMax; + table.Reserves = newtable.Reserves; + table.StandardCode = newtable.StandardCode; + table.StandardName = newtable.StandardName; + table.StandardType = newtable.StandardType; + table.StandardDes = newtable.StandardDes; + table.MeasurementUnit = newtable.MeasurementUnit; + table.MeterMax = newtable.MeterMax; + table.MeterMin = newtable.MeterMin; + table.ThresholdLow1 = newtable.ThresholdLow1; + table.ThresholdLow2 = newtable.ThresholdLow2; + table.ThresholdMax1 = newtable.ThresholdMax1; + table.ThresholdMax2 = newtable.ThresholdMax2; + table.BitNum = newtable.BitNum; + table.DateTime = newtable.DateTime; + table.ProjectId = newtable.ProjectId; + table.Value = newtable.Value; + table.FactoryId = newtable.FactoryId; + table.ReportDate = newtable.ReportDate; + table.ReceiveDate = newtable.ReceiveDate; + db.SubmitChanges(); + } } - } public static void DeleteHazard_RealTimeDeviceById(string ID) { - - Model.Hazard_RealTimeDevice table = db.Hazard_RealTimeDevice.FirstOrDefault(x => x.ID == ID); - if (table != null) + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { - db.Hazard_RealTimeDevice.DeleteOnSubmit(table); - db.SubmitChanges(); + Model.Hazard_RealTimeDevice table = db.Hazard_RealTimeDevice.FirstOrDefault(x => x.ID == ID); + if (table != null) + { + db.Hazard_RealTimeDevice.DeleteOnSubmit(table); + db.SubmitChanges(); + } } } public static void DeleteALLHazard_RealTimeDevice() { - if (db.Hazard_RealTimeDevice != null) + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { - db.Hazard_RealTimeDevice.DeleteAllOnSubmit(db.Hazard_RealTimeDevice); - db.SubmitChanges(); + if (db.Hazard_RealTimeDevice != null) + { + db.Hazard_RealTimeDevice.DeleteAllOnSubmit(db.Hazard_RealTimeDevice); + db.SubmitChanges(); + } } } public static List GetHazard_RealTimeDeviceByDate(DateTime? reportDate) @@ -265,14 +275,15 @@ namespace BLL } public static void DeleteHazard_RealTimeDeviceByDate(DateTime? reportDate) { - - var table = db.Hazard_RealTimeDevice.Where(x => x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0); - if (table != null) + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { - db.Hazard_RealTimeDevice.DeleteAllOnSubmit(table); - db.SubmitChanges(); + var table = db.Hazard_RealTimeDevice.Where(x => x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0); + if (table != null) + { + db.Hazard_RealTimeDevice.DeleteAllOnSubmit(table); + db.SubmitChanges(); + } } - } } } \ No newline at end of file diff --git a/SGGL/BLL/ZHGL/DataSync/LotAPIService.cs b/SGGL/BLL/ZHGL/DataSync/LotAPIService.cs new file mode 100644 index 00000000..d5ab1821 --- /dev/null +++ b/SGGL/BLL/ZHGL/DataSync/LotAPIService.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BLL +{ + public class LotAPIService + { + /// + /// 保存环境监测 + /// + /// + /// + public static string saveEnvironmentCheck(Model.EnvironmentalCheckInput input) + { + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) + { + //使用Emitmapper 将input 映射到实体类db.ZJ_EnvironmentCheck + var entity = EmitMapper.ObjectMapperManager.DefaultInstance.GetMapper().Map(input); + entity.Id = Guid.NewGuid().ToString(); + entity.CreateTime = DateTime.Now; + db.EnvironmentalCheck.InsertOnSubmit(entity); + db.SubmitChanges(); + return entity.Id; + + } + } + + } +} diff --git a/SGGL/BLL/ZHGL/DataSync/MainSevice.cs b/SGGL/BLL/ZHGL/DataSync/MainSevice.cs new file mode 100644 index 00000000..f5522c59 --- /dev/null +++ b/SGGL/BLL/ZHGL/DataSync/MainSevice.cs @@ -0,0 +1,360 @@ +using Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace BLL { + +public class MainSevice +{ + + /// + /// 在建项目集合 + /// + private List _beUnderConstructionList; + private HSSEData_HSSE _hsseData; + private string _unitId; + private int _unitType; + + public MainSevice(string userid) + { + var userModel = UserService.GetUserByUserId(userid); + int unitType = CommonService.GetUnitTypeByUserId(userid); + var projectList = ProjectService.GetProjectWorkList().Select(x => new { x.ProjectId, x.UnitId }).ToList(); + _unitId = userModel.UnitId; + _unitType = unitType; + if (unitType == 0) + { + _beUnderConstructionList = projectList.Select(x => x.ProjectId).ToList(); + _unitId = CommonService.GetThisUnitId(); + } + else if (unitType == 1) + { + _beUnderConstructionList = projectList.Where(x => x.UnitId == userModel.UnitId).Select(x => x.ProjectId).ToList(); + } + else if (unitType == 2) + { + _beUnderConstructionList = new List() { "0" }; + } + + } + public async Task GetHsseDataAsync() + { + try + { + + + // 并行执行异步方法 + var totalEnergyConsumptionTask = ChemicalReportItemService.GetLatstTimeTotalEnergyConsumption(); + var incomeComprehensiveEnergyConsumptionTask = ChemicalReportItemService.GetLatstTimeIncomeComprehensiveEnergyConsumption(); + var newWaterConsumptionTask = ChemicalReportItemService.GetLatstTimeNewWaterConsumption(); + var securityRiskOutputListTask = HSSEData_HSSEService.GetSecurityRiskOutputsAsync() + .ContinueWith(t => t.Result.Where(x => _beUnderConstructionList.Contains(x.ProjectId))); + var largeEngineeringOutputsTask = HSSEData_HSSEService.GetLargeEngineeringOutputsAsync() + .ContinueWith(t => t.Result.Where(x => _beUnderConstructionList.Contains(x.ProjectId))); + var safetyInjectionEngineerTask = HSSEData_HSSEService.GetSafetyInjectionEngineerAsync(); + var certificateATask = HSSEData_HSSEService.GetCertificateAAsync(); + var certificateBTask = HSSEData_HSSEService.GetCertificateBAsync(); + var certificateCTask = HSSEData_HSSEService.GetCertificateCAsync(); + var beUnderConstructionTask = HSSEData_HSSEService.GetBeUnderConstructionAsync(); + var shutdownTask = HSSEData_HSSEService.GetShutdownAsync(); + var joinConstructionPersonTask = HSSEData_HSSEService.GetJoinConstructionPersonAsync(); + var majorProjectsUnderConstructionTask = HSSEData_HSSEService.GetMajorProjectsUnderConstructionAsync(); + var totalWorkingHourTask = HSSEData_HSSEService.GetTotalWorkingHourAsync(); + var lostWorkingHourTask = HSSEData_HSSEService.GetLostWorkingHourAsync(); + var safeWorkingHourTask = HSSEData_HSSEService.GetSafeWorkingHourAsync(); + var safeTrainTask = HSSEData_HSSEService.GetSafeTrainAsync(); + var specialTrainTask = HSSEData_HSSEService.GetSpecialTrainAsync(); + var specialOperationTrainTask = HSSEData_HSSEService.GetSpecialOperationTrainAsync(); + var headOfficeInspectorGeneralTask = HSSEData_HSSEService.GetHeadOfficeInspectorGeneralAsync(); + var headOfficeFullTimeTask = HSSEData_HSSEService.GetHeadOfficeFullTimeAsync(); + var branchInspectorGeneralTask = HSSEData_HSSEService.GetBranchInspectorGeneralAsync(); + var branchFullTimeTask = HSSEData_HSSEService.GetBranchFullTimeAsync(); + var projectInspectorGeneralTask = HSSEData_HSSEService.GetProjectInspectorGeneralAsync(); + var projectFullTimeTask = HSSEData_HSSEService.GetProjectFullTimeAsync(); + var projectSafetyMonitorTask = HSSEData_HSSEService.GetProjectSafetyMonitorAsync(); + var safetyCommitteeMeetingTask = HSSEData_HSSEService.GetSafetyCommitteeMeetingAsync(); + var enterpriseTopicsMeetingTask = HSSEData_HSSEService.GetEnterpriseTopicsMeetingAsync(); + var projectSafetyLeadingGroupMeetingTask = HSSEData_HSSEService.GetProjectSafetyLeadingGroupMeetingAsync(); + var projectSafetyMeetingTask = HSSEData_HSSEService.GetProjectSafetyMeetingAsync(); + var companyLeadShiftCheckTask = HSSEData_HSSEService.GetCompanyLeadShiftCheckAsync(); + var companyComprehensiveCheckTask = HSSEData_HSSEService.GetCompanyComprehensiveCheckAsync(); + var companySpecialCheckTask = HSSEData_HSSEService.GetCompanySpecialCheckAsync(); + var projectLeadShiftCheckTask = HSSEData_HSSEService.GetProjectLeadShiftCheckAsync(); + var projectSpecialCheckTask = HSSEData_HSSEService.GetProjectSpecialCheckAsync(); + var projectMajorCheckTask = HSSEData_HSSEService.GetProjectMajorCheckAsync(); + var nearMissTask = HSSEData_HSSEService.GetNearMissAsync(); + var recordableEventTask = HSSEData_HSSEService.GetRecordableEventAsync(); + var generalAccidentTask = HSSEData_HSSEService.GetGeneralAccidentAsync(); + var majorAccidentTask = HSSEData_HSSEService.GetMajorAccidentAsync(); + var seriousAccidentTask = HSSEData_HSSEService.GetSeriousAccidentAsync(); + var specialSeriousAccidentTask = HSSEData_HSSEService.GetSpecialSeriousAccidentAsync(); + var companyComprehensivePlanTask = HSSEData_HSSEService.GetCompanyComprehensivePlanAsync(); + var companySpecialPlanTask = HSSEData_HSSEService.GetCompanySpecialPlanAsync(); + var companyOnSiteDisposalPlanTask = HSSEData_HSSEService.GetCompanyOnSiteDisposalPlanAsync(); + var companyDrillTask = HSSEData_HSSEService.GetCompanyDrillAsync(); + var projectComprehensivePlanTask = HSSEData_HSSEService.GetProjectComprehensivePlanAsync(); + var projectSpecialPlanTask = HSSEData_HSSEService.GetProjectSpecialPlanAsync(); + var projectOnSiteDisposalPlanTask = HSSEData_HSSEService.GetProjectOnSiteDisposalPlanAsync(); + var projectDrillTask = HSSEData_HSSEService.GetProjectDrillAsync(); + var costExtractTask = HSSEData_HSSEService.GetCostExtractAsync(); + var costUseTask = HSSEData_HSSEService.GetCostUseAsync(); + var useEquipmentTask = HSSEData_HSSEService.GetUseEquipmentAsync(); + var specialEquipmentTask = HSSEData_HSSEService.GetSpecialEquipmentAsync(); + var licensesTask = HSSEData_HSSEService.GetLicensesAsync(); + var licensesCloseTask = HSSEData_HSSEService.GetLicensesCloseAsync(); + var generalHiddenRectificationOutputsTask = HSSEData_HSSEService.GetGeneralHiddenRectificationOutputsAsync(); + var majorHiddenRectificationOutputsTask = HSSEData_HSSEService.GetMajorHiddenRectificationOutputsAsync(); + + // 等待所有异步方法执行完成 + await Task.WhenAll( + securityRiskOutputListTask, + largeEngineeringOutputsTask, + safetyInjectionEngineerTask, + certificateATask, + certificateBTask, + certificateCTask, + beUnderConstructionTask, + shutdownTask, + joinConstructionPersonTask, + majorProjectsUnderConstructionTask, + totalWorkingHourTask, + lostWorkingHourTask, + safeWorkingHourTask, + safeTrainTask, + specialTrainTask, + specialOperationTrainTask, + headOfficeInspectorGeneralTask, + headOfficeFullTimeTask, + branchInspectorGeneralTask, + branchFullTimeTask, + projectInspectorGeneralTask, + projectFullTimeTask, + projectSafetyMonitorTask, + safetyCommitteeMeetingTask, + enterpriseTopicsMeetingTask, + projectSafetyLeadingGroupMeetingTask, + projectSafetyMeetingTask, + companyLeadShiftCheckTask, + companyComprehensiveCheckTask, + companySpecialCheckTask, + projectLeadShiftCheckTask, + projectSpecialCheckTask, + projectMajorCheckTask, + nearMissTask, + recordableEventTask, + generalAccidentTask, + majorAccidentTask, + seriousAccidentTask, + specialSeriousAccidentTask, + companyComprehensivePlanTask, + companySpecialPlanTask, + companyOnSiteDisposalPlanTask, + companyDrillTask, + projectComprehensivePlanTask, + projectSpecialPlanTask, + projectOnSiteDisposalPlanTask, + projectDrillTask, + costExtractTask, + costUseTask, + useEquipmentTask, + specialEquipmentTask, + licensesTask, + licensesCloseTask, + generalHiddenRectificationOutputsTask, + majorHiddenRectificationOutputsTask + ); + + + // 统一获取异步方法的返回值 + var totalEnergyConsumption = totalEnergyConsumptionTask; + var incomeComprehensiveEnergyConsumption = incomeComprehensiveEnergyConsumptionTask; + var newWaterConsumption = newWaterConsumptionTask; + var safetyInjectionEngineerList = await safetyInjectionEngineerTask; + var certificateAList = await certificateATask; + var certificateBList = await certificateBTask; + var certificateCList = await certificateCTask; + var beUnderConstructionList = await beUnderConstructionTask; + var shutdownList = await shutdownTask; + var joinConstructionPersonList = await joinConstructionPersonTask; + var majorProjectsUnderConstructionList = await majorProjectsUnderConstructionTask; + var totalWorkingHour = await totalWorkingHourTask; + var lostWorkingHour = await lostWorkingHourTask; + var safeWorkingHour = await safeWorkingHourTask; + var safeTrainList = await safeTrainTask; + var specialTrainList = await specialTrainTask; + var specialOperationTrainList = await specialOperationTrainTask; + var headOfficeInspectorGeneralList = await headOfficeInspectorGeneralTask; + var headOfficeFullTimeList = await headOfficeFullTimeTask; + var branchInspectorGeneralList = await branchInspectorGeneralTask; + var branchFullTimeList = await branchFullTimeTask; + var projectInspectorGeneralList = await projectInspectorGeneralTask; + var projectFullTimeList = await projectFullTimeTask; + var projectSafetyMonitorList = await projectSafetyMonitorTask; + var safetyCommitteeMeetingList = await safetyCommitteeMeetingTask; + var enterpriseTopicsMeetingList = await enterpriseTopicsMeetingTask; + var projectSafetyLeadingGroupMeetingList = await projectSafetyLeadingGroupMeetingTask; + var projectSafetyMeetingList = await projectSafetyMeetingTask; + var companyLeadShiftCheckList = await companyLeadShiftCheckTask; + var companyComprehensiveCheckList = await companyComprehensiveCheckTask; + var companySpecialCheckList = await companySpecialCheckTask; + var projectLeadShiftCheckList = await projectLeadShiftCheckTask; + var projectSpecialCheckList = await projectSpecialCheckTask; + var projectMajorCheckList = await projectMajorCheckTask; + var nearMissList = await nearMissTask; + var recordableEventList = await recordableEventTask; + var generalAccidentList = await generalAccidentTask; + var majorAccidentList = await majorAccidentTask; + var seriousAccidentList = await seriousAccidentTask; + var specialSeriousAccidentList = await specialSeriousAccidentTask; + var companyComprehensivePlanList = await companyComprehensivePlanTask; + var companySpecialPlanList = await companySpecialPlanTask; + var companyOnSiteDisposalPlanList = await companyOnSiteDisposalPlanTask; + var companyDrillList = await companyDrillTask; + var projectComprehensivePlanList = await projectComprehensivePlanTask; + var projectSpecialPlanList = await projectSpecialPlanTask; + var projectOnSiteDisposalPlanList = await projectOnSiteDisposalPlanTask; + var projectDrillList = await projectDrillTask; + var costExtractList = await costExtractTask; + var costUseList = await costUseTask; + var useEquipmentList = await useEquipmentTask; + var specialEquipmentList = await specialEquipmentTask; + var licensesList = await licensesTask; + var licensesCloseList = await licensesCloseTask; + var generalHiddenRectificationOutputsList = await generalHiddenRectificationOutputsTask; + var majorHiddenRectificationOutputsList = await majorHiddenRectificationOutputsTask; + + // 构造结果对象 + var table = new HSSEData_HSSE + { + JoinConstructionPersonNum = joinConstructionPersonList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)), + MajorProjectsUnderConstructionNum = majorProjectsUnderConstructionList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)), + TotalWorkingHour = totalWorkingHour, + LostWorkingHour = lostWorkingHour, + SafeWorkingHour = safeWorkingHour, + SafeTrainNum = safeTrainList.Where(x => _beUnderConstructionList.Contains(x.ProjectId)).Sum(x => x.TrainPersonNum), + SpecialTrainNum = specialTrainList.Where(x => _beUnderConstructionList.Contains(x.ProjectId)).Sum(x => x.TrainPersonNum), + SpecialOperationTrainNum = specialOperationTrainList.Where(x => _beUnderConstructionList.Contains(x.ProjectId)).Sum(x => x.TrainPersonNum), + EnvironmentalTrainNum = 0, + TotalEnergyConsumption = totalEnergyConsumption, + IncomeComprehensiveEnergyConsumption = incomeComprehensiveEnergyConsumption, + NewWaterConsumption = newWaterConsumption, + HeadOfficeInspectorGeneralNum = headOfficeInspectorGeneralList.Count(), + HeadOfficeFullTimeNum = headOfficeFullTimeList.Count, + BranchInspectorGeneralNum = branchInspectorGeneralList.Count, + BranchFullTimeNum = branchFullTimeList.Count, + ProjectInspectorGeneralNum = projectInspectorGeneralList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)), + ProjectFullTimeNum = projectFullTimeList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)), + ProjectSafetyMonitorNum = projectSafetyMonitorList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)), + ProjectSafetyLeadingGroupMeetingNum = projectSafetyLeadingGroupMeetingList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)), + ProjectSafetyMeetingNum = projectSafetyMeetingList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)), + CompanyLeadShiftCheckNum = companyLeadShiftCheckList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)), + CompanyComprehensiveCheckNum = companyComprehensiveCheckList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)), + CompanySpecialCheckNum = companySpecialCheckList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)), + ProjectLeadShiftCheckNum = projectLeadShiftCheckList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)), + ProjectSpecialCheckNum = projectSpecialCheckList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)), + ProjectMajorCheckNum = projectMajorCheckList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)), + NearMissNum = nearMissList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)), + RecordableEventNum = recordableEventList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)), + GeneralAccidentNum = generalAccidentList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)), + MajorAccidentNum = majorAccidentList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)), + SeriousAccidentNum = seriousAccidentList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)), + SpecialSeriousAccidentNum = specialSeriousAccidentList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)), + CompanyComprehensivePlanNum = companyComprehensivePlanList.Count(x => x.UnitId == _unitId), + CompanySpecialPlanNum = companySpecialPlanList.Count(x => x.UnitId == _unitId), + CompanyOnSiteDisposalPlan = companyOnSiteDisposalPlanList.Count(x => x.UnitId == _unitId), + CompanyDrillNum = companyDrillList.Count(x => x.UnitId.Contains(_unitId)), + ProjectComprehensivePlanNum = projectComprehensivePlanList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)), + ProjectSpecialPlanNum = projectSpecialPlanList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)), + ProjectOnSiteDisposalPlan = projectOnSiteDisposalPlanList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)), + ProjectDrillNum = projectDrillList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)), + CostExtract = Convert.ToInt32(costExtractList.Where(x => _beUnderConstructionList.Contains(x.ProjectId)).Sum(x => x.SUMCost)), + CostUse = Convert.ToInt32(costUseList.Where(x => _beUnderConstructionList.Contains(x.ProjectId)).Sum(x => x.SUMCost)), + UseEquipmentNum = useEquipmentList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)), + SpecialEquipmentNum = specialEquipmentList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)), + LicensesNum = licensesList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)), + LicensesCloseNum = licensesCloseList.Count(x => _beUnderConstructionList.Contains(x.ProjectId)), + GeneralClosedNum = generalHiddenRectificationOutputsList.Where(x => _beUnderConstructionList.Contains(x.ProjectId)).Sum(x => x.RecNum), + GeneralNotClosedNum = generalHiddenRectificationOutputsList.Where(x => _beUnderConstructionList.Contains(x.ProjectId)).Sum(x => x.NoRecNum), + MajorClosedNum = majorHiddenRectificationOutputsList.Where(x => _beUnderConstructionList.Contains(x.ProjectId)).Sum(x => x.RecNum), + MajorNotClosedNum = majorHiddenRectificationOutputsList.Where(x => _beUnderConstructionList.Contains(x.ProjectId)).Sum(x => x.NoRecNum), + LowRiskNum = securityRiskOutputListTask.Result.Sum(x => x.LowRiskNum), + GeneralRiskNum = securityRiskOutputListTask.Result.Sum(x => x.GeneralRiskNum), + MediumRiskNum = securityRiskOutputListTask.Result.Sum(x => x.MediumRiskNum), + HighRiskNum = securityRiskOutputListTask.Result.Sum(x => x.HighRiskNum), + CompletedNum = largeEngineeringOutputsTask.Result.Sum(x => x.CompletedNum), + TrainPersonNum = largeEngineeringOutputsTask.Result.Sum(x => x.TrainPersonNum), + ConstructionNum = largeEngineeringOutputsTask.Result.Sum(x => x.ConstructionNum), + FinishedNum = largeEngineeringOutputsTask.Result.Sum(x => x.FinishedNum), + SuperCompletedNum = largeEngineeringOutputsTask.Result.Sum(x => x.SuperCompletedNum), + SuperTrainPersonNum = largeEngineeringOutputsTask.Result.Sum(x => x.SuperTrainPersonNum), + SuperConstructionNum = largeEngineeringOutputsTask.Result.Sum(x => x.SuperConstructionNum) + }; + + if (_unitType == 0) + { + table.BeUnderConstructionNum = beUnderConstructionList.Count(); + table.ShutdownNum = shutdownList.Count(); + table.SafetyInjectionEngineer = safetyInjectionEngineerList.Count(); + table.EnterpriseTopicsMeetingNum = enterpriseTopicsMeetingList.Count(); + table.CertificateANum = certificateAList.Count(); + table.CertificateBNum = certificateBList.Count(); + table.CertificateCNum = certificateCList.Count(); + table.SafetyCommitteeMeetingNum = safetyCommitteeMeetingList.Count(); + + } + else if (_unitType == 1) + { + table.BeUnderConstructionNum = beUnderConstructionList.Count(x => x.UnitId == _unitId); + table.ShutdownNum = shutdownList.Count(x => x.UnitId == _unitId); + table.SafetyCommitteeMeetingNum = safetyCommitteeMeetingList.Count(x => x.UnitId == _unitId); + table.SafetyInjectionEngineer = safetyInjectionEngineerList.Count(x => _beUnderConstructionList.Contains(x.ProjectId) || x.UnitId == _unitId); + table.EnterpriseTopicsMeetingNum = safetyInjectionEngineerList.Count(x => _beUnderConstructionList.Contains(x.ProjectId) || x.UnitId == _unitId); + table.CertificateANum = certificateAList.Count(x => _beUnderConstructionList.Contains(x.ProjectId) || x.UnitId == _unitId); + table.CertificateBNum = certificateBList.Count(x => _beUnderConstructionList.Contains(x.ProjectId) || x.UnitId == _unitId); + table.CertificateCNum = certificateCList.Count(x => _beUnderConstructionList.Contains(x.ProjectId) || x.UnitId == _unitId); + } + + _hsseData = table; + return _hsseData; + } + catch (Exception ex) + { + + throw; + } + } + + public List GetDataHiddenDangerDetailItems() + { + var db = Funs.DB; + var list = from x in db.HSSE_Hazard_HazardRegister + where _beUnderConstructionList.Contains(x.ProjectId) + select x; + var data = (from x in list + join y in db.HSSE_Hazard_HazardRegisterTypes on x.RegisterTypesId equals y.RegisterTypesId + group x by new + { x.ProjectId, x.RegisterTypesId, y.RegisterTypesName } + into g + select new + { + UnitId = _unitId, + ProjectId = g.Key.ProjectId, + TypeName = g.Key.RegisterTypesName, + TotalNum = g.Count(), + NeedRectifyNum = g.Count(x => x.States == "1"), + }).ToList(); + + var result = (from x in data + group x by x.TypeName into g + select new Model.HSSEDataHiddenDangerDetailItem + { + Id = SQLHelper.GetNewID(), + TypeName = g.Key, + NeedRectifyNum = g.Sum(p => p.NeedRectifyNum), + TotalNum = g.Sum(p => p.TotalNum) + }).ToList(); + return result; + } +} } \ No newline at end of file diff --git a/SGGL/BLL/ZHGL/DataSync/ProjectDataSync/Project_CQMSDataService.cs b/SGGL/BLL/ZHGL/DataSync/ProjectDataSync/Project_CQMSDataService.cs index 535bb675..6e0cd9c7 100644 --- a/SGGL/BLL/ZHGL/DataSync/ProjectDataSync/Project_CQMSDataService.cs +++ b/SGGL/BLL/ZHGL/DataSync/ProjectDataSync/Project_CQMSDataService.cs @@ -156,47 +156,50 @@ namespace BLL /// public static void AddProject_CQMSData_CQMS(Model.Project_CQMSData_CQMS newtable) { - - Model.Project_CQMSData_CQMS table = new Model.Project_CQMSData_CQMS + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { - Id = newtable.Id, - ProjectId = newtable.ProjectId, - 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, - }; - db.Project_CQMSData_CQMS.InsertOnSubmit(table); - db.SubmitChanges(); + Model.Project_CQMSData_CQMS table = new Model.Project_CQMSData_CQMS + { + Id = newtable.Id, + ProjectId = newtable.ProjectId, + 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, + }; + db.Project_CQMSData_CQMS.InsertOnSubmit(table); + db.SubmitChanges(); + } + } /// /// 修改 @@ -204,46 +207,48 @@ namespace BLL /// public static void UpdateProject_CQMSData_CQMS(Model.Project_CQMSData_CQMS newtable) { - - Model.Project_CQMSData_CQMS table = db.Project_CQMSData_CQMS.FirstOrDefault(x => x.Id == newtable.Id); - if (table != null) + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { - table.Id = newtable.Id; - table.ProjectId = newtable.ProjectId; - 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; - db.SubmitChanges(); + Model.Project_CQMSData_CQMS table = db.Project_CQMSData_CQMS.FirstOrDefault(x => x.Id == newtable.Id); + if (table != null) + { + table.Id = newtable.Id; + table.ProjectId = newtable.ProjectId; + 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; + db.SubmitChanges(); + } } } @@ -253,12 +258,14 @@ namespace BLL /// public static void DeleteProject_CQMSData_CQMSById(string Id) { - - Model.Project_CQMSData_CQMS table = db.Project_CQMSData_CQMS.FirstOrDefault(x => x.Id == Id); - if (table != null) + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { - db.Project_CQMSData_CQMS.DeleteOnSubmit(table); - db.SubmitChanges(); + Model.Project_CQMSData_CQMS table = db.Project_CQMSData_CQMS.FirstOrDefault(x => x.Id == Id); + if (table != null) + { + db.Project_CQMSData_CQMS.DeleteOnSubmit(table); + db.SubmitChanges(); + } } } @@ -412,7 +419,7 @@ namespace BLL public static int GetTrainPersonNum(string projectid) { var result = (from x in Funs.DB.Comprehensive_InspectionPerson - where x.ProjectId == projectid && x.IsTrain == true && x.CompileDate>Const.DtmarkTime + where x.ProjectId == projectid && x.IsTrain == true && x.CompileDate > Const.DtmarkTime select x).Count(); return result; } @@ -422,7 +429,7 @@ namespace BLL /// public static int GetTechnicalDisclosePersonNum(string projectid) { - var result = (from x in Funs.DB.Comprehensive_DesignDetails + var result = (from x in Funs.DB.Comprehensive_DesignDetails where x.ProjectId == projectid && x.CompileDate > Const.DtmarkTime select x.JoinPersonNum).ToList().Sum(x => x.Value); var q = Funs.GetNewIntOrZero(result.ToString()); @@ -488,7 +495,7 @@ namespace BLL /// public static int GetProblemNum(string projectid) { - int result = (from x in Funs.DB.Check_CheckControl + int result = (from x in Funs.DB.Check_CheckControl where x.ProjectId == projectid && x.CheckDate > Const.DtmarkTime select x).Count(); return result; @@ -567,7 +574,7 @@ namespace BLL { int result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId - where y.ProjectId == projectid && y.CheckAcceptType == "1" && x.CreateDate> Const.DtmarkTime + where y.ProjectId == projectid && y.CheckAcceptType == "1" && x.CreateDate > Const.DtmarkTime select x).Count(); return result; } @@ -580,7 +587,7 @@ namespace BLL int 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 y.ProjectId == projectid && y.CheckAcceptType == "1" && z.IsOnceQualified == true && x.CreateDate>Const.DtmarkTime + where y.ProjectId == projectid && y.CheckAcceptType == "1" && z.IsOnceQualified == true && x.CreateDate > Const.DtmarkTime select x).Count(); return result; } @@ -691,7 +698,7 @@ namespace BLL public static int GetSingleProjectNum(string projectid) { int result = (from x in Funs.DB.Project_Installation - where x.ProjectId == projectid && x.SuperInstallationId == "0" + where x.ProjectId == projectid && x.SuperInstallationId == "0" select x).Count(); return result; } @@ -702,7 +709,7 @@ namespace BLL public static int GetUnitProjectNum(string projectid) { int result = (from x in Funs.DB.WBS_UnitWork - where x.ProjectId == projectid && (x.SuperUnitWork == null || x.SuperUnitWork == "0") + where x.ProjectId == projectid select x).Count(); return result; } @@ -735,11 +742,40 @@ namespace BLL public static int GetInspectionLotNum(string projectid) { int result = (from x in Funs.DB.WBS_BreakdownProject - where x.ProjectId == projectid && x.IsSelected == true + where x.ProjectId == projectid && x.IsSelected == true select x).Count(); return result; } + #region 推送项目质量数据 + + /// + /// 推送项目质量数据 + /// + /// + public static ReturnData PushProjectCQMSData() + { + var items = (from x in db.Project_CQMSData_CQMS + where x.ReportDate == DateTime.Now.Date + select x).ToList(); + Model.ReturnData responeData = new Model.ReturnData(); + if (items.Count() > 0) + { + var thisUnit = CommonService.GetIsThisUnit(); + var newItem = new { CollCropCode = thisUnit.CollCropCode, Items = items }; + var str = JsonConvert.SerializeObject(newItem); + var baseurl = "/api/CQMSData/SaveProjectCQMSData"; + responeData = ServerService.PushCNCEC(str, baseurl); + } + else + { + responeData.code = 0; + responeData.message = "当前没有项目质量数据"; + } + return responeData; + } + + #endregion } } \ No newline at end of file diff --git a/SGGL/BLL/ZHGL/DataSync/ProjectDataSync/Project_HJGLData_DefectService.cs b/SGGL/BLL/ZHGL/DataSync/ProjectDataSync/Project_HJGLData_DefectService.cs index 5cee8ace..277d6704 100644 --- a/SGGL/BLL/ZHGL/DataSync/ProjectDataSync/Project_HJGLData_DefectService.cs +++ b/SGGL/BLL/ZHGL/DataSync/ProjectDataSync/Project_HJGLData_DefectService.cs @@ -1,4 +1,5 @@ using FineUIPro; +using Microsoft.SqlServer.Dts.Runtime; using NPOI.SS.Formula.Functions; using System; using System.Collections; @@ -86,6 +87,10 @@ namespace BLL public static void AddProject_HJGLData_Defect(Project_HJGLData_Defect newtable) { + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) + { + } + var table = new Project_HJGLData_Defect { Id = newtable.Id, @@ -103,56 +108,71 @@ namespace BLL public static void AddBulkProject_HJGLData_Defect(List newtables) { + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) + { + } db.Project_HJGLData_Defect.InsertAllOnSubmit(newtables); db.SubmitChanges(); } public static void UpdateProject_HJGLData_Defect(Project_HJGLData_Defect newtable) { - var table = db.Project_HJGLData_Defect.FirstOrDefault(x => x.Id == newtable.Id); - if (table != null) + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { - table.Id = newtable.Id; - table.ProjectId = newtable.ProjectId; - table.UnitId = newtable.UnitId; - table.CollCropCode = newtable.CollCropCode; - table.UnitName = newtable.UnitName; - table.ReportDate = newtable.ReportDate; - table.DefectName = newtable.DefectName; - table.DefectNum = newtable.DefectNum; - db.SubmitChanges(); + var table = db.Project_HJGLData_Defect.FirstOrDefault(x => x.Id == newtable.Id); + if (table != null) + { + table.Id = newtable.Id; + table.ProjectId = newtable.ProjectId; + table.UnitId = newtable.UnitId; + table.CollCropCode = newtable.CollCropCode; + table.UnitName = newtable.UnitName; + table.ReportDate = newtable.ReportDate; + table.DefectName = newtable.DefectName; + table.DefectNum = newtable.DefectNum; + db.SubmitChanges(); + } } } public static void DeleteProject_HJGLData_DefectById(string Id) { - var table = db.Project_HJGLData_Defect.FirstOrDefault(x => x.Id == Id); - if (table != null) + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { - db.Project_HJGLData_Defect.DeleteOnSubmit(table); - db.SubmitChanges(); + var table = db.Project_HJGLData_Defect.FirstOrDefault(x => x.Id == Id); + if (table != null) + { + db.Project_HJGLData_Defect.DeleteOnSubmit(table); + db.SubmitChanges(); + } } } public static void DeleteProject_HJGLData_DefectByDate(DateTime? reportDate) { - var table = db.Project_HJGLData_Defect.Where(x => - x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0); - if (table != null) + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { - db.Project_HJGLData_Defect.DeleteAllOnSubmit(table); - db.SubmitChanges(); + var table = db.Project_HJGLData_Defect.Where(x => + x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0); + if (table != null) + { + db.Project_HJGLData_Defect.DeleteAllOnSubmit(table); + db.SubmitChanges(); + } } } public static void DeleteProject_HJGLData_DefectByDate(DateTime? reportDate, string projectid) { - var table = db.Project_HJGLData_Defect.Where(x => - x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0 && x.ProjectId == projectid); - if (table != null) + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { - db.Project_HJGLData_Defect.DeleteAllOnSubmit(table); - db.SubmitChanges(); + var table = db.Project_HJGLData_Defect.Where(x => + x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0 && x.ProjectId == projectid); + if (table != null) + { + db.Project_HJGLData_Defect.DeleteAllOnSubmit(table); + db.SubmitChanges(); + } } } @@ -199,7 +219,43 @@ namespace BLL }).ToList(); return q; } - + public static List GetModelByUnitIdAndReportDate(string Unitid, DateTime? reportdate) + { + if (!reportdate.HasValue) + { + return new List(); + } + var projectlist = BLL.ProjectService.GetProjectWorkList(Unitid); + var q = (from x in Funs.DB.Project_HJGLData_Defect + where x.ReportDate == reportdate && projectlist.Select(e => e.ProjectId).Contains(x.ProjectId) + group x by x.DefectName + into g + select new HJGLDataDefectItems + { + Id = SQLHelper.GetNewID(), + DefectName = g.Key, + DefectNum = g.Sum(p => p.DefectNum) + }).ToList(); + return q; + } + public static List GetModelByReportDate( DateTime? reportdate) + { + if (!reportdate.HasValue) + { + return new List(); + } + var q = (from x in Funs.DB.Project_HJGLData_Defect + where x.ReportDate == reportdate + group x by x.DefectName + into g + select new HJGLDataDefectItems + { + Id = SQLHelper.GetNewID(), + DefectName = g.Key, + DefectNum = g.Sum(p => p.DefectNum) + }).ToList(); + return q; + } /// /// 统计所有在建项目数据 /// diff --git a/SGGL/BLL/ZHGL/DataSync/ProjectDataSync/Project_HJGLData_HJGLService.cs b/SGGL/BLL/ZHGL/DataSync/ProjectDataSync/Project_HJGLData_HJGLService.cs index f8c5dd65..381b221e 100644 --- a/SGGL/BLL/ZHGL/DataSync/ProjectDataSync/Project_HJGLData_HJGLService.cs +++ b/SGGL/BLL/ZHGL/DataSync/ProjectDataSync/Project_HJGLData_HJGLService.cs @@ -105,64 +105,68 @@ namespace BLL return db.Project_HJGLData_HJGL.FirstOrDefault(x => x.Id == Id); } - public static List GetProject_HJGLData_HJGLByProjectid (string Projectid) + public static List GetProject_HJGLData_HJGLByProjectid(string Projectid) { - var q =( from x in db.Project_HJGLData_HJGL - where x.ProjectId == Projectid - select x).ToList(); + var q = (from x in db.Project_HJGLData_HJGL + where x.ProjectId == Projectid + select x).ToList(); return q; } public static void AddProject_HJGLData_HJGL(Model.Project_HJGLData_HJGL newtable) { - - Model.Project_HJGLData_HJGL table = new Model.Project_HJGLData_HJGL + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { - Id = newtable.Id, - ProjectId = newtable.ProjectId, - UnitId = newtable.UnitId, - CollCropCode = newtable.CollCropCode, - UnitName = newtable.UnitName, - ReportDate = newtable.ReportDate, - WelderNum = newtable.WelderNum, - TotalDineNum = newtable.TotalDineNum, - CompleteDineNum = newtable.CompleteDineNum, - TotalFilmNum = newtable.TotalFilmNum, - OKFilmNum = newtable.OKFilmNum, - }; - db.Project_HJGLData_HJGL.InsertOnSubmit(table); - db.SubmitChanges(); + Model.Project_HJGLData_HJGL table = new Model.Project_HJGLData_HJGL + { + Id = newtable.Id, + ProjectId = newtable.ProjectId, + UnitId = newtable.UnitId, + CollCropCode = newtable.CollCropCode, + UnitName = newtable.UnitName, + ReportDate = newtable.ReportDate, + WelderNum = newtable.WelderNum, + TotalDineNum = newtable.TotalDineNum, + CompleteDineNum = newtable.CompleteDineNum, + TotalFilmNum = newtable.TotalFilmNum, + OKFilmNum = newtable.OKFilmNum, + }; + db.Project_HJGLData_HJGL.InsertOnSubmit(table); + db.SubmitChanges(); + } } public static void UpdateProject_HJGLData_HJGL(Model.Project_HJGLData_HJGL newtable) { - - Model.Project_HJGLData_HJGL table = db.Project_HJGLData_HJGL.FirstOrDefault(x => x.Id == newtable.Id); - if (table != null) + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { - table.Id = newtable.Id; - table.ProjectId = newtable.ProjectId; - table.UnitId = newtable.UnitId; - table.CollCropCode = newtable.CollCropCode; - table.UnitName = newtable.UnitName; - table.ReportDate = newtable.ReportDate; - table.WelderNum = newtable.WelderNum; - table.TotalDineNum = newtable.TotalDineNum; - table.CompleteDineNum = newtable.CompleteDineNum; - table.TotalFilmNum = newtable.TotalFilmNum; - table.OKFilmNum = newtable.OKFilmNum; - db.SubmitChanges(); + Model.Project_HJGLData_HJGL table = db.Project_HJGLData_HJGL.FirstOrDefault(x => x.Id == newtable.Id); + if (table != null) + { + table.Id = newtable.Id; + table.ProjectId = newtable.ProjectId; + table.UnitId = newtable.UnitId; + table.CollCropCode = newtable.CollCropCode; + table.UnitName = newtable.UnitName; + table.ReportDate = newtable.ReportDate; + table.WelderNum = newtable.WelderNum; + table.TotalDineNum = newtable.TotalDineNum; + table.CompleteDineNum = newtable.CompleteDineNum; + table.TotalFilmNum = newtable.TotalFilmNum; + table.OKFilmNum = newtable.OKFilmNum; + db.SubmitChanges(); + } } - } public static void DeleteProject_HJGLData_HJGLById(string Id) { - - Model.Project_HJGLData_HJGL table = db.Project_HJGLData_HJGL.FirstOrDefault(x => x.Id == Id); - if (table != null) + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { - db.Project_HJGLData_HJGL.DeleteOnSubmit(table); - db.SubmitChanges(); + Model.Project_HJGLData_HJGL table = db.Project_HJGLData_HJGL.FirstOrDefault(x => x.Id == Id); + if (table != null) + { + db.Project_HJGLData_HJGL.DeleteOnSubmit(table); + db.SubmitChanges(); + } } - } /// /// 判断该项目的该日期是否统计数据 @@ -226,7 +230,7 @@ namespace BLL /// /// 项目id /// 数据类型 - public static void StatisticalData(string projectid,HJGLDateType hJGLDateType) + public static void StatisticalData(string projectid, HJGLDateType hJGLDateType) { string thisUnitId = string.Empty; var thisUnit = CommonService.GetIsThisUnit(); @@ -242,7 +246,7 @@ namespace BLL } else { - table.Id = SQLHelper.GetNewID(); + table.Id = SQLHelper.GetNewID(); } table.UnitId = thisUnitId; table.CollCropCode = base_Unit.CollCropCode; @@ -250,7 +254,7 @@ namespace BLL table.ProjectId = projectid; table.ReportDate = DateTime.Now.Date; - if (hJGLDateType== HJGLDateType.TotalNumberOfWelders|| hJGLDateType == HJGLDateType.All) + if (hJGLDateType == HJGLDateType.TotalNumberOfWelders || hJGLDateType == HJGLDateType.All) { table.WelderNum = GetWelderNum(projectid); @@ -270,9 +274,9 @@ namespace BLL } if (hJGLDateType == HJGLDateType.DefectAnalysis || hJGLDateType == HJGLDateType.All) { - // Project_HJGLData_DefectService.StatisticalData(projectid); + // Project_HJGLData_DefectService.StatisticalData(projectid); } - + if (IsReportByToday(projectid)) { UpdateProject_HJGLData_HJGL(table); @@ -302,30 +306,6 @@ namespace BLL public static int GetTotalDineNum(string projectid) { int result = 0; - if (projectid != null) - { - var getD1 = from x in Funs.DB.HJGL_FL_TotalQuantity - where x.ProjectId == projectid.ToString() - select x; - if (getD1.Count() > 0) - { - foreach (var item in getD1) - { - result += Funs.GetNewIntOrZero(item.TotalWeldQuantity.Split('.')[0]); - } - } - else - { - var getD2 = (from x in Funs.DB.HJGL_FL_Data - where x.ProjectId == projectid.ToString() - orderby x.CompileDate descending - select x).FirstOrDefault(); - if (getD2 != null) - { - result = Funs.GetNewIntOrZero(getD2.TotalWeldQuantity.Split('.')[0]); - } - } - } return result; } /// @@ -335,30 +315,6 @@ namespace BLL public static int GetCompleteDineNum(string projectid) { int result = 0; - if (projectid != null) - { - var getD1 = from x in Funs.DB.HJGL_FL_TotalQuantity - where x.ProjectId == projectid.ToString() - select x; - if (getD1.Count() > 0) - { - foreach (var item in getD1) - { - result += Funs.GetNewIntOrZero(item.TotalCompleted.Split('.')[0]); - } - } - else - { - var getD2 = (from x in Funs.DB.HJGL_FL_Data - where x.ProjectId == projectid.ToString() - orderby x.CompileDate descending - select x).FirstOrDefault(); - if (getD2 != null) - { - result = Funs.GetNewIntOrZero(getD2.TotalCompleted.Split('.')[0]); - } - } - } return result; } /// @@ -368,9 +324,9 @@ namespace BLL public static int GetTotalFilmNum(string projectid) { int result = Convert.ToInt32((from x in Funs.DB.CH_CheckItem - join y in Funs.DB.CH_Check on x.CHT_CheckID equals y.CHT_CheckID - where y.ProjectId == projectid - select x.CHT_TotalFilm ).ToList().Sum()); + join y in Funs.DB.CH_Check on x.CHT_CheckID equals y.CHT_CheckID + where y.ProjectId == projectid + select x.CHT_TotalFilm).ToList().Sum()); return result; } /// @@ -380,11 +336,44 @@ namespace BLL public static int GetOKFilmNum(string projectid) { int result = Convert.ToInt32((from x in Funs.DB.CH_CheckItem - join y in Funs.DB.CH_Check on x.CHT_CheckID equals y.CHT_CheckID - where y.ProjectId == projectid - select x.CHT_PassFilm).ToList().Sum()); + join y in Funs.DB.CH_Check on x.CHT_CheckID equals y.CHT_CheckID + where y.ProjectId == projectid + select x.CHT_PassFilm).ToList().Sum()); return result; } + + #region 推送项目焊接数据 + + /// + /// 推送项目焊接数据 + /// + /// + public static ReturnData PushProjectHJGLData() + { + var items = (from x in db.Project_HJGLData_HJGL + where x.ReportDate == DateTime.Now.Date + select x).ToList(); + var defectItems = (from x in db.Project_HJGLData_Defect + where x.ReportDate == DateTime.Now.Date + select x).ToList(); + Model.ReturnData responeData = new Model.ReturnData(); + if (items.Count() > 0 || defectItems.Count() > 0) + { + var thisUnit = CommonService.GetIsThisUnit(); + var newItem = new { CollCropCode = thisUnit.CollCropCode, Items = items, DefectItems = defectItems }; + var str = JsonConvert.SerializeObject(newItem); + var baseurl = "/api/HJGLData/SaveProjectHJGLData"; + responeData = ServerService.PushCNCEC(str, baseurl); + } + else + { + responeData.code = 0; + responeData.message = "当前没有项目焊接数据"; + } + return responeData; + } + + #endregion } } \ No newline at end of file diff --git a/SGGL/BLL/ZHGL/DataSync/ProjectDataSync/Project_HSSEData_HSSEService.cs b/SGGL/BLL/ZHGL/DataSync/ProjectDataSync/Project_HSSEData_HSSEService.cs index 5919bba3..631ac191 100644 --- a/SGGL/BLL/ZHGL/DataSync/ProjectDataSync/Project_HSSEData_HSSEService.cs +++ b/SGGL/BLL/ZHGL/DataSync/ProjectDataSync/Project_HSSEData_HSSEService.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Linq; using FineUIPro; using Model; +using Newtonsoft.Json; namespace BLL { @@ -226,8 +227,8 @@ namespace BLL using (var db = new SGGLDB(Funs.ConnString)) { var q = (from x in db.Project_HSSEData_HSSE - where x.ProjectId == Projectid - select x).ToList(); + where x.ProjectId == Projectid + select x).ToList(); return q; } } @@ -320,6 +321,19 @@ namespace BLL } } + public static void DeleteProject_HSSEData_HSSEByDate(DateTime? reportDate) + { + using (var db = new SGGLDB(Funs.ConnString)) + { + var table = db.Project_HSSEData_HSSE.Where(x => x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0); + if (table != null) + { + db.Project_HSSEData_HSSE.DeleteAllOnSubmit(table); + db.SubmitChanges(); + } + } + } + /// /// 判断该项目的该日期是否统计数据 /// @@ -330,9 +344,9 @@ namespace BLL { var result = false; var q = (from x in Funs.DB.Project_HSSEData_HSSE - where x.ReportDate >= dateTime.Date && x.ReportDate < dateTime.Date.AddDays(1).Date && - x.ProjectId == projectid - select x).ToList(); + where x.ReportDate >= dateTime.Date && x.ReportDate < dateTime.Date.AddDays(1).Date && + x.ProjectId == projectid + select x).ToList(); if (q != null && q.Count > 0) result = true; return result; } @@ -345,9 +359,9 @@ namespace BLL { var result = false; var q = (from x in Funs.DB.Project_HSSEData_HSSE - where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date && - x.ProjectId == projectid - select x).ToList(); + where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date && + x.ProjectId == projectid + select x).ToList(); if (q != null && q.Count > 0) result = true; return result; } @@ -360,9 +374,9 @@ namespace BLL public static Project_HSSEData_HSSE getProject_HSSEData_HSSEByDate(string projectid) { var q = (from x in Funs.DB.Project_HSSEData_HSSE - where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date && - x.ProjectId == projectid - select x).FirstOrDefault(); + where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date && + x.ProjectId == projectid + select x).FirstOrDefault(); return q; } @@ -526,10 +540,10 @@ namespace BLL DateTime date = DateTime.Now; Model.SGGLDB db1 = Funs.DB; var list = from x in db1.HSSE_Hazard_HazardRegister - select x; + select x; var types = (from x in db1.HSSE_Hazard_HazardRegisterTypes - join y in list on x.RegisterTypesId equals y.RegisterTypesId - select new { x.RegisterTypesId, x.RegisterTypesName }).Distinct().ToList(); + join y in list on x.RegisterTypesId equals y.RegisterTypesId + select new { x.RegisterTypesId, x.RegisterTypesName }).Distinct().ToList(); foreach (var type in types) { Model.Project_HSSEData_HiddenDangerDetail table1 = new Model.Project_HSSEData_HiddenDangerDetail @@ -541,7 +555,7 @@ namespace BLL ReportDate = DateTime.Now.Date, TypeName = type.RegisterTypesName, TotalNum = list.Count(x => x.RegisterTypesId == type.RegisterTypesId), - NeedRectifyNum = list.Count(x => x.RegisterTypesId == type.RegisterTypesId && (x.States == "1" )), + NeedRectifyNum = list.Count(x => x.RegisterTypesId == type.RegisterTypesId && (x.States == "1")), }; if (Project_HSSEData_HiddenDangerDetailService.IsReportByToday(projectid, type.RegisterTypesName)) { @@ -582,8 +596,8 @@ namespace BLL public static int GetBeUnderConstructionNum(string projectid) { var result = (from x in Funs.DB.Base_Project - where x.ProjectState == "1" && x.ProjectId == projectid - select x).Count(); + where x.ProjectState == "1" && x.ProjectId == projectid + select x).Count(); return result; } @@ -594,8 +608,8 @@ namespace BLL public static int GetShutdownNum(string projectid) { var result = (from x in Funs.DB.Base_Project - where x.ProjectState == "2" && x.ProjectId == projectid - select x).Count(); + where x.ProjectState == "2" && x.ProjectId == projectid + select x).Count(); return result; } @@ -606,8 +620,8 @@ namespace BLL public static int GetJoinConstructionPersonNum(string projectid) { var result = (from x in Funs.DB.SitePerson_Person - where x.ProjectId == projectid && x.IsUsed == true - select x).Count(); + where x.ProjectId == projectid && x.IsUsed == true + select x).Count(); return result; } @@ -618,8 +632,8 @@ namespace BLL public static int GetMajorProjectsUnderConstructionNum(string projectid) { var result = (from x in Funs.DB.Solution_LargerHazard - where x.ProjectId == projectid && x.States == "2" && x.RecordTime > Const.DtmarkTime - select x).Count(); + where x.ProjectId == projectid && x.States == "2" && x.RecordTime > Const.DtmarkTime + select x).Count(); return result; } @@ -630,9 +644,9 @@ namespace BLL public static int GetTotalWorkingHour(string projectid) { var result = (from x in Funs.DB.SitePerson_DayReportDetail - join y in Funs.DB.SitePerson_DayReport on x.DayReportId equals y.DayReportId - where y.ProjectId == projectid && y.CompileDate > Const.DtmarkTime - select x.PersonWorkTime ?? 0).ToList().Sum(); + join y in Funs.DB.SitePerson_DayReport on x.DayReportId equals y.DayReportId + where y.ProjectId == projectid && y.CompileDate > Const.DtmarkTime + select x.PersonWorkTime ?? 0).ToList().Sum(); var q = Funs.GetNewIntOrZero(result.ToString().Split('.')[0]); return q; @@ -646,12 +660,12 @@ namespace BLL { var result = (from x in Funs.DB.Accident_AccidentHandle - where x.ProjectId == projectid && x.CompileDate > Const.DtmarkTime - select x.WorkHoursLoss) + where x.ProjectId == projectid && x.CompileDate > Const.DtmarkTime + select x.WorkHoursLoss) .ToList().Sum(x => x.Value) + (from x in Funs.DB.Accident_AccidentReport - where x.ProjectId == projectid && x.CompileDate > Const.DtmarkTime - select x.WorkingHoursLoss) + where x.ProjectId == projectid && x.CompileDate > Const.DtmarkTime + select x.WorkingHoursLoss) .ToList().Sum(x => x.Value); var q = Funs.GetNewIntOrZero(result.ToString().Split('.')[0]); @@ -665,17 +679,17 @@ namespace BLL public static int GetSafeWorkingHour(string projectid) { var result1 = (from x in Funs.DB.SitePerson_DayReportDetail - join y in Funs.DB.SitePerson_DayReport on x.DayReportId equals y.DayReportId - where y.ProjectId == projectid && y.CompileDate > Const.DtmarkTime - select x.PersonWorkTime ?? 0).ToList().Sum(); + join y in Funs.DB.SitePerson_DayReport on x.DayReportId equals y.DayReportId + where y.ProjectId == projectid && y.CompileDate > Const.DtmarkTime + select x.PersonWorkTime ?? 0).ToList().Sum(); var result2 = (from x in Funs.DB.Accident_AccidentHandle - where x.ProjectId == projectid && x.CompileDate > Const.DtmarkTime - select x.WorkHoursLoss) + where x.ProjectId == projectid && x.CompileDate > Const.DtmarkTime + select x.WorkHoursLoss) .ToList().Sum(x => x.Value) + (from x in Funs.DB.Accident_AccidentReport - where x.ProjectId == projectid && x.CompileDate > Const.DtmarkTime - select x.WorkingHoursLoss) + where x.ProjectId == projectid && x.CompileDate > Const.DtmarkTime + select x.WorkingHoursLoss) .ToList().Sum(x => x.Value); var result = result1 - result2; var q = Funs.GetNewIntOrZero(result.ToString().Split('.')[0]); @@ -690,9 +704,9 @@ namespace BLL public static int GetSafeTrainNum(string projectid) { var result = (from x in Funs.DB.EduTrain_TrainRecord - join y in Funs.DB.Base_TrainType on x.TrainTypeId equals y.TrainTypeId - where x.ProjectId == projectid && y.TrainType == "1" && x.TrainStartDate > Const.DtmarkTime - select x).Count(); + join y in Funs.DB.Base_TrainType on x.TrainTypeId equals y.TrainTypeId + where x.ProjectId == projectid && y.TrainType == "1" && x.TrainStartDate > Const.DtmarkTime + select x.TrainPersonNum ?? 0).ToList().Sum(); return result; } @@ -703,9 +717,9 @@ namespace BLL public static int GetSpecialTrainNum(string projectid) { var result = (from x in Funs.DB.EduTrain_TrainRecord - join y in Funs.DB.Base_TrainType on x.TrainTypeId equals y.TrainTypeId - where x.ProjectId == projectid && y.TrainType == "2" && x.TrainStartDate > Const.DtmarkTime - select x).Count(); + join y in Funs.DB.Base_TrainType on x.TrainTypeId equals y.TrainTypeId + where x.ProjectId == projectid && y.TrainType == "2" && x.TrainStartDate > Const.DtmarkTime + select x.TrainPersonNum ?? 0).ToList().Sum(); return result; } @@ -716,9 +730,9 @@ namespace BLL public static int GetSpecialOperationTrainNum(string projectid) { var result = (from x in Funs.DB.EduTrain_TrainRecord - join y in Funs.DB.Base_TrainType on x.TrainTypeId equals y.TrainTypeId - where x.ProjectId == projectid && y.TrainType == "3" && x.TrainStartDate > Const.DtmarkTime - select x).Count(); + join y in Funs.DB.Base_TrainType on x.TrainTypeId equals y.TrainTypeId + where x.ProjectId == projectid && y.TrainType == "3" && x.TrainStartDate > Const.DtmarkTime + select x.TrainPersonNum ?? 0).ToList().Sum(); return result; } @@ -799,8 +813,8 @@ namespace BLL public static int GetProjectInspectorGeneralNum(string projectid) { var result = (from x in Funs.DB.SitePerson_Person - where x.ProjectId == projectid && x.WorkPostId == Const.WorkPost_ProjectHSSEDirector && x.IsUsed == true - select x).Count(); + where x.ProjectId == projectid && x.WorkPostId == Const.WorkPost_ProjectHSSEDirector && x.IsUsed == true + select x).Count(); return result; } @@ -811,9 +825,9 @@ namespace BLL public static int GetProjectFullTimeNum(string projectid) { var result = (from x in Funs.DB.SitePerson_Person - join y in Funs.DB.Base_WorkPost on x.WorkPostId equals y.WorkPostId - where x.ProjectId == projectid && y.IsHsse == true && x.IsUsed == true - select x).Count(); + join y in Funs.DB.Base_WorkPost on x.WorkPostId equals y.WorkPostId + where x.ProjectId == projectid && y.IsHsse == true && x.IsUsed == true + select x).Count(); return result; } @@ -824,8 +838,8 @@ namespace BLL public static int GetProjectSafetyMonitorNum(string projectid) { var result = (from x in Funs.DB.SitePerson_Person - where x.ProjectId == projectid && x.IsSafetyMonitoring == true && x.IsUsed == true - select x).Count(); + where x.ProjectId == projectid && x.IsSafetyMonitoring == true && x.IsUsed == true + select x).Count(); return result; } @@ -836,9 +850,9 @@ namespace BLL public static int GetSafetyInjectionEngineer(string projectid) { var result = (from x in Funs.DB.SitePerson_Person - join y in Funs.DB.Base_Certificate on x.CertificateId equals y.CertificateId - where x.ProjectId == projectid && y.IsRegisterHSSE == true && x.IsUsed == true - select x).Count(); + join y in Funs.DB.Base_Certificate on x.CertificateId equals y.CertificateId + where x.ProjectId == projectid && y.IsRegisterHSSE == true && x.IsUsed == true + select x).Count(); return result; } @@ -849,9 +863,10 @@ namespace BLL public static int GetCertificateANum(string projectid) { var result = (from x in Funs.DB.SitePerson_Person - join y in Funs.DB.Base_Certificate on x.CertificateId equals y.CertificateId - where x.ProjectId == projectid && y.CertificateType == "A" && x.IsUsed == true - select x).Count(); + join y in Funs.DB.QualityAudit_PersonQuality on x.PersonId equals y.PersonId + join z in Funs.DB.Base_Certificate on y.CertificateId equals z.CertificateId + where x.ProjectId == projectid && z.CertificateType == "A" && x.IsUsed == true + select x).Count(); return result; } @@ -862,9 +877,10 @@ namespace BLL public static int GetCertificateBNum(string projectid) { var result = (from x in Funs.DB.SitePerson_Person - join y in Funs.DB.Base_Certificate on x.CertificateId equals y.CertificateId - where x.ProjectId == projectid && y.CertificateType == "B" && x.IsUsed == true - select x).Count(); + join y in Funs.DB.QualityAudit_PersonQuality on x.PersonId equals y.PersonId + join z in Funs.DB.Base_Certificate on y.CertificateId equals z.CertificateId + where x.ProjectId == projectid && z.CertificateType == "B" && x.IsUsed == true + select x).Count(); return result; } @@ -875,9 +891,10 @@ namespace BLL public static int GetCertificateCNum(string projectid) { var result = (from x in Funs.DB.SitePerson_Person - join y in Funs.DB.Base_Certificate on x.CertificateId equals y.CertificateId - where x.ProjectId == projectid && y.CertificateType == "C" && x.IsUsed == true - select x).Count(); + join y in Funs.DB.QualityAudit_PersonQuality on x.PersonId equals y.PersonId + join z in Funs.DB.Base_Certificate on y.CertificateId equals z.CertificateId + where x.ProjectId == projectid && z.CertificateType == "C" && x.IsUsed == true + select x).Count(); return result; } @@ -908,8 +925,8 @@ namespace BLL public static int GetProjectSafetyLeadingGroupMeetingNum(string projectid) { var result = (from x in Funs.DB.Meeting_SafetyLeaderGroupMeeting - where x.ProjectId == projectid && x.CompileDate > Const.DtmarkTime - select x) + where x.ProjectId == projectid && x.CompileDate > Const.DtmarkTime + select x) .Count(); return result; } @@ -921,11 +938,11 @@ namespace BLL public static int GetProjectSafetyMeetingNum(string projectid) { var result = (from x in Funs.DB.Meeting_WeekMeeting - where x.ProjectId == projectid && x.CompileDate > Const.DtmarkTime - select x).Count() + where x.ProjectId == projectid && x.CompileDate > Const.DtmarkTime + select x).Count() + (from x in Funs.DB.Meeting_MonthMeeting - where x.ProjectId == projectid && x.CompileDate > Const.DtmarkTime - select x).Count(); + where x.ProjectId == projectid && x.CompileDate > Const.DtmarkTime + select x).Count(); return result; } @@ -966,8 +983,8 @@ namespace BLL public static int GetProjectLeadShiftCheckNum(string projectid) { var result = (from x in Funs.DB.Check_ProjectLeaderCheck - where x.ProjectId == projectid && x.CompileDate > Const.DtmarkTime - select x).Count(); + where x.ProjectId == projectid && x.CheckDate > Const.DtmarkTime + select x).Count(); return result; } @@ -978,8 +995,8 @@ namespace BLL public static int GetProjectSpecialCheckNum(string projectid) { var result = (from x in Funs.DB.Check_CheckSpecial - where x.ProjectId == projectid && x.CheckTime > Const.DtmarkTime - select x).Count(); + where x.ProjectId == projectid && x.CheckTime > Const.DtmarkTime + select x).Count(); return result; } @@ -990,8 +1007,8 @@ namespace BLL public static int GetProjectMajorCheckNum(string projectid) { var result = (from x in Funs.DB.HSSE_Hazard_HazardRegister - where x.ProjectId == projectid && x.CheckTime > Const.DtmarkTime - select x).Count(); + where x.ProjectId == projectid && x.CheckTime > Const.DtmarkTime + select x).Count(); return result; } @@ -1002,9 +1019,9 @@ namespace BLL public static int GetNearMissNum(string projectid) { var result = (from x in Funs.DB.Accident_AccidentPersonRecord - join y in Funs.DB.Base_AccidentType on x.AccidentTypeId equals y.AccidentTypeId - where x.ProjectId == projectid && x.IsAttempt == "1" && x.CompileDate > Const.DtmarkTime - select x).Count(); + join y in Funs.DB.Base_AccidentType on x.AccidentTypeId equals y.AccidentTypeId + where x.ProjectId == projectid && x.IsAttempt == "1" && x.CompileDate > Const.DtmarkTime + select x).Count(); return result; } @@ -1015,9 +1032,9 @@ namespace BLL public static int GetRecordableEventNum(string projectid) { var result = (from x in Funs.DB.Accident_AccidentPersonRecord - join y in Funs.DB.Base_AccidentType on x.AccidentTypeId equals y.AccidentTypeId - where x.ProjectId == projectid && x.CompileDate > Const.DtmarkTime - select x).Count(); + join y in Funs.DB.Base_AccidentType on x.AccidentTypeId equals y.AccidentTypeId + where x.ProjectId == projectid && x.CompileDate > Const.DtmarkTime + select x).Count(); return result; } @@ -1028,8 +1045,8 @@ namespace BLL public static int GetGeneralAccidentNum(string projectid) { var result = (from x in Funs.DB.Accident_AccidentReport - where x.ProjectId == projectid && x.AccidentDegree == "1" && x.CompileDate > Const.DtmarkTime - select x).Count(); + where x.ProjectId == projectid && x.AccidentDegree == "1" && x.CompileDate > Const.DtmarkTime + select x).Count(); return result; } @@ -1040,8 +1057,8 @@ namespace BLL public static int GetMajorAccidentNum(string projectid) { var result = (from x in Funs.DB.Accident_AccidentReport - where x.ProjectId == projectid && x.AccidentDegree == "2" && x.CompileDate > Const.DtmarkTime - select x).Count(); + where x.ProjectId == projectid && x.AccidentDegree == "2" && x.CompileDate > Const.DtmarkTime + select x).Count(); return result; } @@ -1052,8 +1069,8 @@ namespace BLL public static int GetSeriousAccidentNum(string projectid) { var result = (from x in Funs.DB.Accident_AccidentReport - where x.ProjectId == projectid && x.AccidentDegree == "3" && x.CompileDate > Const.DtmarkTime - select x).Count(); + where x.ProjectId == projectid && x.AccidentDegree == "3" && x.CompileDate > Const.DtmarkTime + select x).Count(); return result; } @@ -1064,8 +1081,8 @@ namespace BLL public static int GetSpecialSeriousAccidentNum(string projectid) { var result = (from x in Funs.DB.Accident_AccidentReport - where x.ProjectId == projectid && x.AccidentDegree == "4" - select x).Count(); + where x.ProjectId == projectid && x.AccidentDegree == "4" + select x).Count(); return result; } @@ -1116,9 +1133,9 @@ namespace BLL public static int GetProjectComprehensivePlanNum(string projectid) { var result = (from x in Funs.DB.Emergency_EmergencyList - join y in Funs.DB.Base_EmergencyType on x.EmergencyTypeId equals y.EmergencyTypeId - where x.ProjectId == projectid && y.EmergencyTypeName.Contains("综合") && x.CompileDate > Const.DtmarkTime - select x).Count(); + join y in Funs.DB.Base_EmergencyType on x.EmergencyTypeId equals y.EmergencyTypeId + where x.ProjectId == projectid && y.EmergencyTypeName.Contains("综合") && x.CompileDate > Const.DtmarkTime + select x).Count(); return result; } @@ -1129,9 +1146,9 @@ namespace BLL public static int GetProjectSpecialPlanNum(string projectid) { var result = (from x in Funs.DB.Emergency_EmergencyList - join y in Funs.DB.Base_EmergencyType on x.EmergencyTypeId equals y.EmergencyTypeId - where x.ProjectId == projectid && y.EmergencyTypeName.Contains("专项") && x.CompileDate > Const.DtmarkTime - select x).Count(); + join y in Funs.DB.Base_EmergencyType on x.EmergencyTypeId equals y.EmergencyTypeId + where x.ProjectId == projectid && y.EmergencyTypeName.Contains("专项") && x.CompileDate > Const.DtmarkTime + select x).Count(); return result; } @@ -1142,10 +1159,10 @@ namespace BLL public static int GetProjectOnSiteDisposalPlan(string projectid) { var result = (from x in Funs.DB.Emergency_EmergencyList - join y in Funs.DB.Base_EmergencyType on x.EmergencyTypeId equals y.EmergencyTypeId - where x.ProjectId == projectid && y.EmergencyTypeName.Contains("现场处置") && - x.CompileDate > Const.DtmarkTime - select x).Count(); + join y in Funs.DB.Base_EmergencyType on x.EmergencyTypeId equals y.EmergencyTypeId + where x.ProjectId == projectid && y.EmergencyTypeName.Contains("现场处置") && + x.CompileDate > Const.DtmarkTime + select x).Count(); return result; } @@ -1156,8 +1173,8 @@ namespace BLL public static int GetProjectDrillNum(string projectid) { var result = (from x in Funs.DB.Emergency_DrillRecordList - where x.ProjectId == projectid && x.CompileDate > Const.DtmarkTime - select x).Count(); + where x.ProjectId == projectid && x.CompileDate > Const.DtmarkTime + select x).Count(); return result; } @@ -1179,10 +1196,10 @@ namespace BLL { var result = 0; var costs = (from x in Funs.DB.CostGoods_CostSmallDetailItem - join y in Funs.DB.CostGoods_CostSmallDetail - on x.CostSmallDetailId equals y.CostSmallDetailId - where y.ProjectId == projectid && y.CompileDate > Const.DtmarkTime - select x.CostMoney ?? 0).ToList().Sum(); + join y in Funs.DB.CostGoods_CostSmallDetail + on x.CostSmallDetailId equals y.CostSmallDetailId + where y.ProjectId == projectid && y.CompileDate > Const.DtmarkTime + select x.CostMoney ?? 0).ToList().Sum(); result = Funs.GetNewIntOrZero(costs.ToString().Split('.')[0]); return result; } @@ -1194,14 +1211,14 @@ namespace BLL public static int GetUseEquipmentNum(string projectid) { var result = (from x in Funs.DB.InApproveManager_EquipmentInItem - join y in Funs.DB.InApproveManager_EquipmentIn on x.EquipmentInId equals y.EquipmentInId - where y.ProjectId == projectid && x.IsUsed == true - select x).Count() + + join y in Funs.DB.InApproveManager_EquipmentIn on x.EquipmentInId equals y.EquipmentInId + where y.ProjectId == projectid && x.IsUsed == true + select x).Count() + (from x in Funs.DB.InApproveManager_GeneralEquipmentInItem - join y in Funs.DB.InApproveManager_GeneralEquipmentIn on x.GeneralEquipmentInId equals y - .GeneralEquipmentInId - where y.ProjectId == projectid && x.IsUsed == true - select x).Count(); + join y in Funs.DB.InApproveManager_GeneralEquipmentIn on x.GeneralEquipmentInId equals y + .GeneralEquipmentInId + where y.ProjectId == projectid && x.IsUsed == true + select x).Count(); return result; } @@ -1212,9 +1229,9 @@ namespace BLL public static int GetSpecialEquipmentNum(string projectid) { var result = (from x in Funs.DB.InApproveManager_EquipmentInItem - join y in Funs.DB.InApproveManager_EquipmentIn on x.EquipmentInId equals y.EquipmentInId - where y.ProjectId == projectid && x.IsUsed == true - select x).Count(); + join y in Funs.DB.InApproveManager_EquipmentIn on x.EquipmentInId equals y.EquipmentInId + where y.ProjectId == projectid && x.IsUsed == true + select x).Count(); return result; } @@ -1225,8 +1242,8 @@ namespace BLL public static int GetLicensesNum(string projectid) { var result = (from x in Funs.DB.License_LicenseManager - where x.ProjectId == projectid && x.IsHighRisk == true && x.CompileDate > Const.DtmarkTime - select x).Count(); + where x.ProjectId == projectid && x.IsHighRisk == true && x.CompileDate > Const.DtmarkTime + select x).Count(); return result; } @@ -1237,9 +1254,9 @@ namespace BLL public static int GetLicensesCloseNum(string projectid) { var result = (from x in Funs.DB.License_LicenseManager - where x.ProjectId == projectid && x.IsHighRisk == true && x.WorkStates == "3" && - x.CompileDate > Const.DtmarkTime - select x).Count(); + where x.ProjectId == projectid && x.IsHighRisk == true && x.WorkStates == "3" && + x.CompileDate > Const.DtmarkTime + select x).Count(); return result; } @@ -1250,9 +1267,9 @@ namespace BLL public static int GetGeneralClosedNum(string projectid) { var result = (from x in Funs.DB.HSSE_Hazard_HazardRegister - where x.ProjectId == projectid && x.Risk_Level == "一般" && x.States == "3" && - x.CheckTime > Const.DtmarkTime - select x).Count(); + where x.ProjectId == projectid && x.Risk_Level == "一般" && x.States == "3" && + x.CheckTime > Const.DtmarkTime + select x).Count(); return result; } @@ -1263,9 +1280,9 @@ namespace BLL public static int GetGeneralNotClosedNum(string projectid) { var result = (from x in Funs.DB.HSSE_Hazard_HazardRegister - where x.ProjectId == projectid && x.Risk_Level == "一般" && x.States != "3" && - x.CheckTime > Const.DtmarkTime - select x).Count(); + where x.ProjectId == projectid && x.Risk_Level == "一般" && x.States != "3" && x.States != "-1" && + x.CheckTime > Const.DtmarkTime + select x).Count(); return result; } @@ -1276,9 +1293,9 @@ namespace BLL public static int GetMajorClosedNum(string projectid) { var result = (from x in Funs.DB.HSSE_Hazard_HazardRegister - where x.ProjectId == projectid && x.Risk_Level == "重大" && x.States == "3" && - x.CheckTime > Const.DtmarkTime - select x).Count(); + where x.ProjectId == projectid && x.Risk_Level == "重大" && x.States == "3" && + x.CheckTime > Const.DtmarkTime + select x).Count(); return result; } @@ -1289,9 +1306,9 @@ namespace BLL public static int GetMajorNotClosedNum(string projectid) { var result = (from x in Funs.DB.HSSE_Hazard_HazardRegister - where x.ProjectId == projectid && x.Risk_Level == "重大" && x.States != "3" && - x.CheckTime > Const.DtmarkTime - select x).Count(); + where x.ProjectId == projectid && x.Risk_Level == "重大" && x.States != "3" && x.States != "-1" && + x.CheckTime > Const.DtmarkTime + select x).Count(); return result; } @@ -1303,8 +1320,7 @@ namespace BLL { var result = (from x in Funs.DB.Hazard_HazardSelectedItem join y in Funs.DB.Base_RiskLevel on x.HazardLevel equals y.RiskLevelId - join z in Funs.DB.Hazard_HazardList on x.HazardListId equals z.HazardListId - where z.ProjectId == projectid && y.RiskLevel == 2 && z.CompileDate.Value.Year >= 2023 + where x.ProjectId == projectid && (y.RiskLevel == 2 || x.HazardLevel == "2") && (x.IsStart == true || x.State == "1") select x).Count(); return result; } @@ -1317,8 +1333,7 @@ namespace BLL { var result = (from x in Funs.DB.Hazard_HazardSelectedItem join y in Funs.DB.Base_RiskLevel on x.HazardLevel equals y.RiskLevelId - join z in Funs.DB.Hazard_HazardList on x.HazardListId equals z.HazardListId - where z.ProjectId == projectid && y.RiskLevel == 1 && z.CompileDate.Value.Year >= 2023 + where x.ProjectId == projectid && (y.RiskLevel == 1 || x.HazardLevel == "1") && (x.IsStart == true || x.State == "1") select x).Count(); return result; } @@ -1331,8 +1346,7 @@ namespace BLL { var result = (from x in Funs.DB.Hazard_HazardSelectedItem join y in Funs.DB.Base_RiskLevel on x.HazardLevel equals y.RiskLevelId - join z in Funs.DB.Hazard_HazardList on x.HazardListId equals z.HazardListId - where z.ProjectId == projectid && y.RiskLevel == 3 && z.CompileDate.Value.Year >= 2023 + where x.ProjectId == projectid && (y.RiskLevel == 3 || x.HazardLevel == "3") && (x.IsStart == true || x.State == "1") select x).Count(); return result; } @@ -1345,8 +1359,7 @@ namespace BLL { var result = (from x in Funs.DB.Hazard_HazardSelectedItem join y in Funs.DB.Base_RiskLevel on x.HazardLevel equals y.RiskLevelId - join z in Funs.DB.Hazard_HazardList on x.HazardListId equals z.HazardListId - where z.ProjectId == projectid && y.RiskLevel == 4 && z.CompileDate.Value.Year >= 2023 + where x.ProjectId == projectid && y.RiskLevel == 4 && (x.IsStart == true || x.State == "1") select x).Count(); return result; } @@ -1358,9 +1371,9 @@ namespace BLL public static int GetCompletedNum(string projectid) { var result = (from x in Funs.DB.Solution_LargerHazard - where x.ProjectId == projectid && x.States != "0" && x.IsSuperLargerHazard == false && - x.RecordTime > Const.DtmarkTime - select x).Count(); + where x.ProjectId == projectid && x.States == "1" && x.IsSuperLargerHazard == false && + x.RecordTime > Const.DtmarkTime + select x).Count(); return result; } @@ -1371,8 +1384,8 @@ namespace BLL public static int GetTrainPersonNum(string projectid) { var result = (from x in Funs.DB.Solution_LargerHazard - where x.ProjectId == projectid && x.IsSuperLargerHazard == false && x.RecordTime > Const.DtmarkTime - select x.TrainPersonNum).ToList().Sum(x => x.Value); + where x.ProjectId == projectid && x.IsSuperLargerHazard == false && x.RecordTime > Const.DtmarkTime + select x.TrainPersonNum).ToList().Sum(x => x.Value); return result; } @@ -1383,9 +1396,9 @@ namespace BLL public static int GetConstructionNum(string projectid) { var result = (from x in Funs.DB.Solution_LargerHazard - where x.ProjectId == projectid && x.States == "2" && x.IsSuperLargerHazard == false && - x.RecordTime > Const.DtmarkTime - select x).Count(); + where x.ProjectId == projectid && x.States == "2" && x.IsSuperLargerHazard == false && + x.RecordTime > Const.DtmarkTime + select x).Count(); return result; } @@ -1396,9 +1409,9 @@ namespace BLL public static int GetFinishedNum(string projectid) { var result = (from x in Funs.DB.Solution_LargerHazard - where x.ProjectId == projectid && x.States == "3" && x.IsSuperLargerHazard == false && - x.RecordTime > Const.DtmarkTime - select x).Count(); + where x.ProjectId == projectid && x.States == "3" && x.IsSuperLargerHazard == false && + x.RecordTime > Const.DtmarkTime + select x).Count(); return result; } @@ -1409,9 +1422,9 @@ namespace BLL public static int GetSuperCompletedNum(string projectid) { var result = (from x in Funs.DB.Solution_LargerHazard - where x.ProjectId == projectid && x.States != "0" && x.IsSuperLargerHazard == true && - x.RecordTime > Const.DtmarkTime - select x).Count(); + where x.ProjectId == projectid && x.States == "1" && x.IsSuperLargerHazard == true && + x.RecordTime > Const.DtmarkTime + select x).Count(); return result; } @@ -1423,8 +1436,8 @@ namespace BLL { var result = (from x in Funs.DB.Solution_LargerHazard - where x.ProjectId == projectid && x.IsSuperLargerHazard == true && x.RecordTime > Const.DtmarkTime - select x.TrainPersonNum).ToList().Sum(x => x.Value); + where x.ProjectId == projectid && x.IsSuperLargerHazard == true && x.RecordTime > Const.DtmarkTime + select x.TrainPersonNum).ToList().Sum(x => x.Value); return result; } @@ -1435,9 +1448,9 @@ namespace BLL public static int GetSuperConstructionNum(string projectid) { var result = (from x in Funs.DB.Solution_LargerHazard - where x.ProjectId == projectid && x.States == "2" && x.IsSuperLargerHazard == true && - x.RecordTime > Const.DtmarkTime - select x).Count(); + where x.ProjectId == projectid && x.States == "2" && x.IsSuperLargerHazard == true && + x.RecordTime > Const.DtmarkTime + select x).Count(); return result; } @@ -1448,9 +1461,9 @@ namespace BLL public static int GetSuperFinishedNum(string projectid) { var result = (from x in Funs.DB.Solution_LargerHazard - where x.ProjectId == projectid && x.States == "3" && x.IsSuperLargerHazard == true && - x.RecordTime > Const.DtmarkTime - select x).Count(); + where x.ProjectId == projectid && x.States == "3" && x.IsSuperLargerHazard == true && + x.RecordTime > Const.DtmarkTime + select x).Count(); return result; } @@ -1487,85 +1500,118 @@ namespace BLL if (Count == 0) return null; // q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize); return from x in q - select new - { - x.Id, - x.ProjectId, - x.UnitId, - x.CollCropCode, - x.UnitName, - x.ReportDate, - x.BeUnderConstructionNum, - x.ShutdownNum, - x.JoinConstructionPersonNum, - x.MajorProjectsUnderConstructionNum, - x.TotalWorkingHour, - x.LostWorkingHour, - x.SafeWorkingHour, - x.SafeTrainNum, - x.SpecialTrainNum, - x.SpecialOperationTrainNum, - x.TotalEnergyConsumption, - x.IncomeComprehensiveEnergyConsumption, - x.NewWaterConsumption, - x.HeadOfficeInspectorGeneralNum, - x.HeadOfficeFullTimeNum, - x.BranchInspectorGeneralNum, - x.BranchFullTimeNum, - x.ProjectInspectorGeneralNum, - x.ProjectFullTimeNum, - x.ProjectSafetyMonitorNum, - x.SafetyInjectionEngineer, - x.CertificateANum, - x.CertificateBNum, - x.CertificateCNum, - x.SafetyCommitteeMeetingNum, - x.EnterpriseTopicsMeetingNum, - x.ProjectSafetyLeadingGroupMeetingNum, - x.ProjectSafetyMeetingNum, - x.CompanyLeadShiftCheckNum, - x.CompanyComprehensiveCheckNum, - x.CompanySpecialCheckNum, - x.ProjectLeadShiftCheckNum, - x.ProjectSpecialCheckNum, - x.ProjectMajorCheckNum, - x.NearMissNum, - x.RecordableEventNum, - x.GeneralAccidentNum, - x.MajorAccidentNum, - x.SeriousAccidentNum, - x.SpecialSeriousAccidentNum, - x.CompanyComprehensivePlanNum, - x.CompanySpecialPlanNum, - x.CompanyOnSiteDisposalPlan, - x.CompanyDrillNum, - x.ProjectComprehensivePlanNum, - x.ProjectSpecialPlanNum, - x.ProjectOnSiteDisposalPlan, - x.ProjectDrillNum, - x.CostExtract, - x.CostUse, - x.UseEquipmentNum, - x.SpecialEquipmentNum, - x.LicensesNum, - x.LicensesCloseNum, - x.GeneralClosedNum, - x.GeneralNotClosedNum, - x.MajorClosedNum, - x.MajorNotClosedNum, - x.GeneralRiskNum, - x.LowRiskNum, - x.MediumRiskNum, - x.HighRiskNum, - x.CompletedNum, - x.TrainPersonNum, - x.ConstructionNum, - x.FinishedNum, - x.SuperCompletedNum, - x.SuperTrainPersonNum, - x.SuperConstructionNum, - x.SuperFinishedNum - }; + select new + { + x.Id, + x.ProjectId, + x.UnitId, + x.CollCropCode, + x.UnitName, + x.ReportDate, + x.BeUnderConstructionNum, + x.ShutdownNum, + x.JoinConstructionPersonNum, + x.MajorProjectsUnderConstructionNum, + x.TotalWorkingHour, + x.LostWorkingHour, + x.SafeWorkingHour, + x.SafeTrainNum, + x.SpecialTrainNum, + x.SpecialOperationTrainNum, + x.TotalEnergyConsumption, + x.IncomeComprehensiveEnergyConsumption, + x.NewWaterConsumption, + x.HeadOfficeInspectorGeneralNum, + x.HeadOfficeFullTimeNum, + x.BranchInspectorGeneralNum, + x.BranchFullTimeNum, + x.ProjectInspectorGeneralNum, + x.ProjectFullTimeNum, + x.ProjectSafetyMonitorNum, + x.SafetyInjectionEngineer, + x.CertificateANum, + x.CertificateBNum, + x.CertificateCNum, + x.SafetyCommitteeMeetingNum, + x.EnterpriseTopicsMeetingNum, + x.ProjectSafetyLeadingGroupMeetingNum, + x.ProjectSafetyMeetingNum, + x.CompanyLeadShiftCheckNum, + x.CompanyComprehensiveCheckNum, + x.CompanySpecialCheckNum, + x.ProjectLeadShiftCheckNum, + x.ProjectSpecialCheckNum, + x.ProjectMajorCheckNum, + x.NearMissNum, + x.RecordableEventNum, + x.GeneralAccidentNum, + x.MajorAccidentNum, + x.SeriousAccidentNum, + x.SpecialSeriousAccidentNum, + x.CompanyComprehensivePlanNum, + x.CompanySpecialPlanNum, + x.CompanyOnSiteDisposalPlan, + x.CompanyDrillNum, + x.ProjectComprehensivePlanNum, + x.ProjectSpecialPlanNum, + x.ProjectOnSiteDisposalPlan, + x.ProjectDrillNum, + x.CostExtract, + x.CostUse, + x.UseEquipmentNum, + x.SpecialEquipmentNum, + x.LicensesNum, + x.LicensesCloseNum, + x.GeneralClosedNum, + x.GeneralNotClosedNum, + x.MajorClosedNum, + x.MajorNotClosedNum, + x.GeneralRiskNum, + x.LowRiskNum, + x.MediumRiskNum, + x.HighRiskNum, + x.CompletedNum, + x.TrainPersonNum, + x.ConstructionNum, + x.FinishedNum, + x.SuperCompletedNum, + x.SuperTrainPersonNum, + x.SuperConstructionNum, + x.SuperFinishedNum + }; + } + + #endregion + + #region 推送项目安全隐患风险数据 + + /// + /// 推送项目安全隐患风险数据 + /// + /// + public static ReturnData PushProjectHSSEData() + { + var items = (from x in db.Project_HSSEData_HSSE + where x.ReportDate == DateTime.Now.Date + select x).ToList(); + var detailItems = (from x in db.Project_HSSEData_HiddenDangerDetail + where x.ReportDate == DateTime.Now.Date + select x).ToList(); + Model.ReturnData responeData = new Model.ReturnData(); + if (items.Count() > 0 || detailItems.Count() > 0) + { + var thisUnit = CommonService.GetIsThisUnit(); + var newItem = new { CollCropCode = thisUnit.CollCropCode, Items = items, DetailItems = detailItems }; + var str = JsonConvert.SerializeObject(newItem); + var baseurl = "/api/HSSEData/SaveProjectHSSEData"; + responeData = ServerService.PushCNCEC(str, baseurl); + } + else + { + responeData.code = 0; + responeData.message = "当前没有项目安全隐患风险数据"; + } + return responeData; } #endregion diff --git a/SGGL/BLL/ZHGL/DataSync/ProjectDataSync/Project_HSSEData_HiddenDangerDetailService.cs b/SGGL/BLL/ZHGL/DataSync/ProjectDataSync/Project_HSSEData_HiddenDangerDetailService.cs index 3897e5ec..b9968bd2 100644 --- a/SGGL/BLL/ZHGL/DataSync/ProjectDataSync/Project_HSSEData_HiddenDangerDetailService.cs +++ b/SGGL/BLL/ZHGL/DataSync/ProjectDataSync/Project_HSSEData_HiddenDangerDetailService.cs @@ -1,4 +1,5 @@ using FineUIPro; +using Microsoft.SqlServer.Dts.Runtime; using Model; using System; using System.Collections; @@ -115,9 +116,10 @@ namespace BLL { using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { + db.Project_HSSEData_HiddenDangerDetail.InsertAllOnSubmit(newtables); db.SubmitChanges(); - } + } } public static void UpdateProject_HSSEData_HiddenDangerDetail(Model.Project_HSSEData_HiddenDangerDetail newtable) { @@ -208,6 +210,10 @@ namespace BLL select x).FirstOrDefault(); return q; } + /// + /// 获取当天的隐患类别数据 + /// + /// public static List GetTodayModel() { var q = (from x in Funs.DB.Project_HSSEData_HiddenDangerDetail @@ -222,6 +228,60 @@ namespace BLL }).ToList(); return q; } + /// + /// 根据单位id和日期 获取单位关联项目次日期的数据 + /// + /// + /// + /// + public static List GetModelByUnitIdAndReportDate(string Unitid, DateTime? reportdate) + { + var projectlist = BLL.ProjectService.GetProjectWorkList(Unitid); + var q = (from x in Funs.DB.Project_HSSEData_HiddenDangerDetail + where x.ReportDate == reportdate && projectlist.Select(e => e.ProjectId).Contains(x.ProjectId) + group x by x.TypeName into g + select new Model.HSSEDataHiddenDangerDetailItem + { + Id = SQLHelper.GetNewID(), + TypeName = g.Key, + NeedRectifyNum = g.Sum(p => p.NeedRectifyNum), + TotalNum = g.Sum(p => p.TotalNum) + }).ToList(); + return q; + } + /// + /// 根据日期 获取隐患类别数据 + /// + /// + /// + public static List GetModelByReportDate( DateTime? reportdate) + { + var q = (from x in Funs.DB.Project_HSSEData_HiddenDangerDetail + where x.ReportDate == reportdate + group x by x.TypeName into g + select new Model.HSSEDataHiddenDangerDetailItem + { + Id = SQLHelper.GetNewID(), + TypeName = g.Key, + NeedRectifyNum = g.Sum(p => p.NeedRectifyNum), + TotalNum = g.Sum(p => p.TotalNum) + }).ToList(); + return q; + } + public static List GetModelByReportDate(DateTime? reportdate,string projectid) + { + var q = (from x in Funs.DB.Project_HSSEData_HiddenDangerDetail + where x.ReportDate == reportdate && x.ProjectId==projectid + group x by x.TypeName into g + select new Model.HSSEDataHiddenDangerDetailItem + { + Id = SQLHelper.GetNewID(), + TypeName = g.Key, + NeedRectifyNum = g.Sum(p => p.NeedRectifyNum), + TotalNum = g.Sum(p => p.TotalNum) + }).ToList(); + return q; + } public static void StatisticalAllProjectData() { var db = Funs.DB; diff --git a/SGGL/BLL/ZHGL/DataSync/ProjectDataSync/Project_SYHSEData_SYHSEService.cs b/SGGL/BLL/ZHGL/DataSync/ProjectDataSync/Project_SYHSEData_SYHSEService.cs index 189d7baa..a6cef0c4 100644 --- a/SGGL/BLL/ZHGL/DataSync/ProjectDataSync/Project_SYHSEData_SYHSEService.cs +++ b/SGGL/BLL/ZHGL/DataSync/ProjectDataSync/Project_SYHSEData_SYHSEService.cs @@ -142,113 +142,120 @@ namespace BLL } public static void AddProject_SYHSEData_SYHSE(Model.Project_SYHSEData_SYHSE newtable) { - - Model.Project_SYHSEData_SYHSE table = new Model.Project_SYHSEData_SYHSE + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { - Id = newtable.Id, - ProjectId = newtable.ProjectId, - UnitId = newtable.UnitId, - CollCropCode = newtable.CollCropCode, - UnitName = newtable.UnitName, - ReportDate = newtable.ReportDate, - GeneralRiskNum = newtable.GeneralRiskNum, - LowRiskNum = newtable.LowRiskNum, - MediumRiskNum = newtable.MediumRiskNum, - HighRiskNum = newtable.HighRiskNum, - GradedResponsiblePersonNum = newtable.GradedResponsiblePersonNum, - ChargeInsurancePersonNum = newtable.ChargeInsurancePersonNum, - DesignQuantity = newtable.DesignQuantity, - RunningCapacity = newtable.RunningCapacity, - InterlockSettingValue = newtable.InterlockSettingValue, - VideoSurveillanceNum = newtable.VideoSurveillanceNum, - TotalWorkinghours = newtable.TotalWorkinghours, - SafeWorkinghours = newtable.SafeWorkinghours, - LostWorkinghours = newtable.LostWorkinghours, - TotalEnergyConsumption = newtable.TotalEnergyConsumption, - IncomeComprehensiveEnergyConsumption = newtable.IncomeComprehensiveEnergyConsumption, - NewWaterConsumption = newtable.NewWaterConsumption, - GeneralClosedNum = newtable.GeneralClosedNum, - GeneralNotClosedNum = newtable.GeneralNotClosedNum, - MajorClosedNum = newtable.MajorClosedNum, - MajorNotClosedNum = newtable.MajorNotClosedNum, - HotWorkPermitNum = newtable.HotWorkPermitNum, - HotWorkClosedNum = newtable.HotWorkClosedNum, - HighPermitNum = newtable.HighPermitNum, - HighClosedNum = newtable.HighClosedNum, - TemporaryElectricityPermitNum = newtable.TemporaryElectricityPermitNum, - TemporaryElectricityClosedNum = newtable.TemporaryElectricityClosedNum, - BlindPlatePermitNum = newtable.BlindPlatePermitNum, - BlindPlateClosedNum = newtable.BlindPlateClosedNum, - GroundbreakingPermitNum = newtable.GroundbreakingPermitNum, - GroundbreakingClosedNum = newtable.GroundbreakingClosedNum, - OpenCircuitPermitNum = newtable.OpenCircuitPermitNum, - OpenCircuitClosedNum = newtable.OpenCircuitClosedNum, - HoistingPermitNum = newtable.HoistingPermitNum, - HoistingClosedNum = newtable.HoistingClosedNum, - }; - db.Project_SYHSEData_SYHSE.InsertOnSubmit(table); - db.SubmitChanges(); + Model.Project_SYHSEData_SYHSE table = new Model.Project_SYHSEData_SYHSE + { + Id = newtable.Id, + ProjectId = newtable.ProjectId, + UnitId = newtable.UnitId, + CollCropCode = newtable.CollCropCode, + UnitName = newtable.UnitName, + ReportDate = newtable.ReportDate, + GeneralRiskNum = newtable.GeneralRiskNum, + LowRiskNum = newtable.LowRiskNum, + MediumRiskNum = newtable.MediumRiskNum, + HighRiskNum = newtable.HighRiskNum, + GradedResponsiblePersonNum = newtable.GradedResponsiblePersonNum, + ChargeInsurancePersonNum = newtable.ChargeInsurancePersonNum, + DesignQuantity = newtable.DesignQuantity, + RunningCapacity = newtable.RunningCapacity, + InterlockSettingValue = newtable.InterlockSettingValue, + VideoSurveillanceNum = newtable.VideoSurveillanceNum, + TotalWorkinghours = newtable.TotalWorkinghours, + SafeWorkinghours = newtable.SafeWorkinghours, + LostWorkinghours = newtable.LostWorkinghours, + TotalEnergyConsumption = newtable.TotalEnergyConsumption, + IncomeComprehensiveEnergyConsumption = newtable.IncomeComprehensiveEnergyConsumption, + NewWaterConsumption = newtable.NewWaterConsumption, + GeneralClosedNum = newtable.GeneralClosedNum, + GeneralNotClosedNum = newtable.GeneralNotClosedNum, + MajorClosedNum = newtable.MajorClosedNum, + MajorNotClosedNum = newtable.MajorNotClosedNum, + HotWorkPermitNum = newtable.HotWorkPermitNum, + HotWorkClosedNum = newtable.HotWorkClosedNum, + HighPermitNum = newtable.HighPermitNum, + HighClosedNum = newtable.HighClosedNum, + TemporaryElectricityPermitNum = newtable.TemporaryElectricityPermitNum, + TemporaryElectricityClosedNum = newtable.TemporaryElectricityClosedNum, + BlindPlatePermitNum = newtable.BlindPlatePermitNum, + BlindPlateClosedNum = newtable.BlindPlateClosedNum, + GroundbreakingPermitNum = newtable.GroundbreakingPermitNum, + GroundbreakingClosedNum = newtable.GroundbreakingClosedNum, + OpenCircuitPermitNum = newtable.OpenCircuitPermitNum, + OpenCircuitClosedNum = newtable.OpenCircuitClosedNum, + HoistingPermitNum = newtable.HoistingPermitNum, + HoistingClosedNum = newtable.HoistingClosedNum, + }; + db.Project_SYHSEData_SYHSE.InsertOnSubmit(table); + db.SubmitChanges(); + } + + } public static void UpdateProject_SYHSEData_SYHSE(Model.Project_SYHSEData_SYHSE newtable) { - - Model.Project_SYHSEData_SYHSE table = db.Project_SYHSEData_SYHSE.FirstOrDefault(x => x.Id == newtable.Id); - if (table != null) + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { - table.Id = newtable.Id; - table.ProjectId=newtable.ProjectId; - table.UnitId = newtable.UnitId; - table.CollCropCode = newtable.CollCropCode; - table.UnitName = newtable.UnitName; - table.ReportDate = newtable.ReportDate; - table.GeneralRiskNum = newtable.GeneralRiskNum; - table.LowRiskNum = newtable.LowRiskNum; - table.MediumRiskNum = newtable.MediumRiskNum; - table.HighRiskNum = newtable.HighRiskNum; - table.GradedResponsiblePersonNum = newtable.GradedResponsiblePersonNum; - table.ChargeInsurancePersonNum = newtable.ChargeInsurancePersonNum; - table.DesignQuantity = newtable.DesignQuantity; - table.RunningCapacity = newtable.RunningCapacity; - table.InterlockSettingValue = newtable.InterlockSettingValue; - table.VideoSurveillanceNum = newtable.VideoSurveillanceNum; - table.TotalWorkinghours = newtable.TotalWorkinghours; - table.SafeWorkinghours = newtable.SafeWorkinghours; - table.LostWorkinghours = newtable.LostWorkinghours; - table.TotalEnergyConsumption = newtable.TotalEnergyConsumption; - table.IncomeComprehensiveEnergyConsumption = newtable.IncomeComprehensiveEnergyConsumption; - table.NewWaterConsumption = newtable.NewWaterConsumption; - table.GeneralClosedNum = newtable.GeneralClosedNum; - table.GeneralNotClosedNum = newtable.GeneralNotClosedNum; - table.MajorClosedNum = newtable.MajorClosedNum; - table.MajorNotClosedNum = newtable.MajorNotClosedNum; - table.HotWorkPermitNum = newtable.HotWorkPermitNum; - table.HotWorkClosedNum = newtable.HotWorkClosedNum; - table.HighPermitNum = newtable.HighPermitNum; - table.HighClosedNum = newtable.HighClosedNum; - table.TemporaryElectricityPermitNum = newtable.TemporaryElectricityPermitNum; - table.TemporaryElectricityClosedNum = newtable.TemporaryElectricityClosedNum; - table.BlindPlatePermitNum = newtable.BlindPlatePermitNum; - table.BlindPlateClosedNum = newtable.BlindPlateClosedNum; - table.GroundbreakingPermitNum = newtable.GroundbreakingPermitNum; - table.GroundbreakingClosedNum = newtable.GroundbreakingClosedNum; - table.OpenCircuitPermitNum = newtable.OpenCircuitPermitNum; - table.OpenCircuitClosedNum = newtable.OpenCircuitClosedNum; - table.HoistingPermitNum = newtable.HoistingPermitNum; - table.HoistingClosedNum = newtable.HoistingClosedNum; - db.SubmitChanges(); - } + Model.Project_SYHSEData_SYHSE table = db.Project_SYHSEData_SYHSE.FirstOrDefault(x => x.Id == newtable.Id); + if (table != null) + { + table.Id = newtable.Id; + table.ProjectId = newtable.ProjectId; + table.UnitId = newtable.UnitId; + table.CollCropCode = newtable.CollCropCode; + table.UnitName = newtable.UnitName; + table.ReportDate = newtable.ReportDate; + table.GeneralRiskNum = newtable.GeneralRiskNum; + table.LowRiskNum = newtable.LowRiskNum; + table.MediumRiskNum = newtable.MediumRiskNum; + table.HighRiskNum = newtable.HighRiskNum; + table.GradedResponsiblePersonNum = newtable.GradedResponsiblePersonNum; + table.ChargeInsurancePersonNum = newtable.ChargeInsurancePersonNum; + table.DesignQuantity = newtable.DesignQuantity; + table.RunningCapacity = newtable.RunningCapacity; + table.InterlockSettingValue = newtable.InterlockSettingValue; + table.VideoSurveillanceNum = newtable.VideoSurveillanceNum; + table.TotalWorkinghours = newtable.TotalWorkinghours; + table.SafeWorkinghours = newtable.SafeWorkinghours; + table.LostWorkinghours = newtable.LostWorkinghours; + table.TotalEnergyConsumption = newtable.TotalEnergyConsumption; + table.IncomeComprehensiveEnergyConsumption = newtable.IncomeComprehensiveEnergyConsumption; + table.NewWaterConsumption = newtable.NewWaterConsumption; + table.GeneralClosedNum = newtable.GeneralClosedNum; + table.GeneralNotClosedNum = newtable.GeneralNotClosedNum; + table.MajorClosedNum = newtable.MajorClosedNum; + table.MajorNotClosedNum = newtable.MajorNotClosedNum; + table.HotWorkPermitNum = newtable.HotWorkPermitNum; + table.HotWorkClosedNum = newtable.HotWorkClosedNum; + table.HighPermitNum = newtable.HighPermitNum; + table.HighClosedNum = newtable.HighClosedNum; + table.TemporaryElectricityPermitNum = newtable.TemporaryElectricityPermitNum; + table.TemporaryElectricityClosedNum = newtable.TemporaryElectricityClosedNum; + table.BlindPlatePermitNum = newtable.BlindPlatePermitNum; + table.BlindPlateClosedNum = newtable.BlindPlateClosedNum; + table.GroundbreakingPermitNum = newtable.GroundbreakingPermitNum; + table.GroundbreakingClosedNum = newtable.GroundbreakingClosedNum; + table.OpenCircuitPermitNum = newtable.OpenCircuitPermitNum; + table.OpenCircuitClosedNum = newtable.OpenCircuitClosedNum; + table.HoistingPermitNum = newtable.HoistingPermitNum; + table.HoistingClosedNum = newtable.HoistingClosedNum; + db.SubmitChanges(); + } + } } public static void DeleteProject_SYHSEData_SYHSEById(string Id) { - - Model.Project_SYHSEData_SYHSE table = db.Project_SYHSEData_SYHSE.FirstOrDefault(x => x.Id == Id); - if (table != null) + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { - db.Project_SYHSEData_SYHSE.DeleteOnSubmit(table); - db.SubmitChanges(); + Model.Project_SYHSEData_SYHSE table = db.Project_SYHSEData_SYHSE.FirstOrDefault(x => x.Id == Id); + if (table != null) + { + db.Project_SYHSEData_SYHSE.DeleteOnSubmit(table); + db.SubmitChanges(); + } } - } /// /// 判断当天是否统计过数据 diff --git a/SGGL/BLL/ZHGL/DataSync/ServerService.cs b/SGGL/BLL/ZHGL/DataSync/ServerService.cs index 490d4fb8..029ab842 100644 --- a/SGGL/BLL/ZHGL/DataSync/ServerService.cs +++ b/SGGL/BLL/ZHGL/DataSync/ServerService.cs @@ -1,25 +1,34 @@ using Model; using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using RestSharp; using System; using System.Collections.Generic; using System.Linq; using System.Net; +using System.Net.Configuration; using System.Security.Policy; using System.Text; using System.Threading.Tasks; +using ResponeData = Model.ResponeData; namespace BLL { + /// + /// 集团服务类 + /// public static class ServerService { + /// + /// 获取集团token + /// + /// public static Model.TokenItem GetCNCECToken() { string CNCECPath = SysConstSetService.CNCECPath; - string baseurl = CNCECPath + "/api/Common/GetToken"; var client = new RestClient(baseurl); - client.Timeout = -1; + client.Timeout = 2000;//获取token设置超时时间为3秒 var request = new RestRequest(Method.POST); ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; var thisUnit = CommonService.GetIsThisUnit(); @@ -28,28 +37,41 @@ namespace BLL //request.AddJsonBody(JsonBody); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content); - var responeData = JsonConvert.DeserializeObject(response.Content.ToString()); TokenItem tokenItem = new TokenItem(); - if (responeData.code == 1 && string.IsNullOrEmpty(responeData.message)) + + try { - var token = JsonConvert.DeserializeObject(responeData.data.ToString()); - tokenItem.Token = token.Token.ToString(); - tokenItem.ExpiryTime = token.ExpiryTime.ToString(); - SysConstSetService.SetToken(tokenItem.Token); - SysConstSetService.SetTokenExpirationTime(tokenItem.ExpiryTime); + var responeData = JsonConvert.DeserializeObject(response.Content.ToString()); + if (responeData != null && responeData.code == 1 && string.IsNullOrEmpty(responeData.message)) + { + var token = JsonConvert.DeserializeObject(responeData.data.ToString()); + tokenItem.Token = token.Token.ToString(); + tokenItem.ExpiryTime = token.ExpiryTime.ToString(); + SysConstSetService.SetToken(tokenItem.Token); + SysConstSetService.SetTokenExpirationTime(tokenItem.ExpiryTime); + } + } + catch (Exception e) + { + } + return tokenItem; } + /// + /// 推送数据至集团(post接口) + /// + /// + /// + /// public static Model.ReturnData PushCNCEC(string JsonBody, string apiurl) { try { - - Model.ReturnData responeData = new Model.ReturnData(); string CNCECPath = SysConstSetService.CNCECPath; - //string CNCECPath = "http://localhost:7143"; + //CNCECPath = "http://localhost:7143"; if (string.IsNullOrEmpty(CNCECPath)) { responeData.code = 0; @@ -78,6 +100,10 @@ namespace BLL throw; } } + /// + /// 获取token + /// + /// public static Model.TokenItem GetToken() { Model.TokenItem tokenItem = new Model.TokenItem(); @@ -95,6 +121,182 @@ namespace BLL } return tokenItem; } + /// + /// 从集团获取数据(Get接口) + /// + /// 接口地址 + /// parameters参数 + /// 超时时间 + /// + public static Model.ResponeData GerDataFromCncec(string apiurl, Dictionary parameters, int? timeout = null) + { + Model.ResponeData responeData = new Model.ResponeData(); + try + { + + string CNCECPath = SysConstSetService.CNCECPath; + if (string.IsNullOrEmpty(CNCECPath)) + { + responeData.code = 0; + responeData.message = "接口地址为空,请配置!"; + return responeData; + + } + string baseurl = CNCECPath + apiurl; + var client = new RestClient(baseurl); + client.Timeout = timeout ?? -1; + var request = new RestRequest(Method.GET); + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + var tokenItem = GetToken(); + if (tokenItem == null || string.IsNullOrEmpty(tokenItem.Token)) + { + responeData.code = 0; + responeData.message = "token 不存在!"; + return responeData; + } + + request.AddHeader("token", tokenItem.Token); + if (parameters != null) + { + foreach (var parameter in parameters) + { + request.AddParameter(parameter.Key, parameter.Value); + } + } + + IRestResponse response = client.Execute(request); + APICommonService.SaveSysHttpLog("api_Out", baseurl, response.Content); + var returnData = JsonConvert.DeserializeObject(response.Content.ToString()); + if (returnData != null) + { + responeData.code = returnData.code; + responeData.message = returnData.message; + responeData.data = returnData.data; + + } + else + { + responeData.code = -1; + responeData.message = "接口有误"; + } + + return responeData; + } + catch (Exception ex) + { + responeData.code = 0; + responeData.message = ex.ToString(); + return responeData; + } + } + + + /// + /// 获取安全合规列表 + /// + /// 类型(1-法律法规;2-标准规范;3-规章制度;4-管理规定) + /// + public static async Task> GetSafeLawListByTypeAsync(string type) + { + // 使用 lambda 表达式来调用 getSafeLawListByType + return await Task.Run(() => GetSafeLawListByType(type)); + } + /// + /// 获取安全合规列表 + /// + /// 类型(1-法律法规;2-标准规范;3-规章制度;4-管理规定) + /// + public static List GetSafeLawListByType(string type) + { + List result = new List(); + string baseurl = "/api/Resources/getSafeLawListByType"; + Dictionary dic = new Dictionary() + { + {"type",type}, + {"pageIndex","0"} + + }; + var returnData = GerDataFromCncec(baseurl, dic, 3000); + if (returnData != null && returnData.code == 1) + { + JObject jt = Newtonsoft.Json.JsonConvert.DeserializeObject(returnData.data.ToString()); + var data = jt["getDataList"].ToString(); + result = JsonConvert.DeserializeObject>(data); + + } + return result; + } + /// + /// 获取公告列表 + /// + /// + public static List GetNoticeList() + { + List result = new List(); + string baseurl = "/api/Notice/getNoticeList"; + Dictionary dic = new Dictionary() + { + {"pageIndex","0"} + + }; + var returnData = GerDataFromCncec(baseurl, dic, 4000); + if (returnData != null && returnData.code == 1) + { + JObject jt = Newtonsoft.Json.JsonConvert.DeserializeObject(returnData.data.ToString()); + var data = jt["getDataList"].ToString(); + result = JsonConvert.DeserializeObject>(data); + + } + return result; + } + /// + /// 获取公告列表 + /// + /// + public static async Task> GetNoticeListAsync() + { + return await Task.Run(() => GetNoticeList()); + } + /// + /// 获取新闻列表 + /// + /// + public static List GetNewsList() + { + List result = new List(); + string baseurl = "/api/Notice/getNewsList"; + Dictionary dic = new Dictionary() + { + {"pageIndex","0"} + + }; + var returnData = GerDataFromCncec(baseurl, dic, 3000); + if (returnData != null && returnData.code == 1) + { + JObject jt = Newtonsoft.Json.JsonConvert.DeserializeObject(returnData.data.ToString()); + var data = jt["getDataList"].ToString(); + result = JsonConvert.DeserializeObject>(data); + + } + return result; + } + /// + /// 获取新闻列表 + /// + /// + public static async Task> GetNewsListAsync() + { + return await Task.Run(() => GetNewsList()); + } + /// + /// 获取QHSEUrl + /// + /// + public static string GetQHSEUrl() + { + var result = GerDataFromCncec("/api/Data/GetWebUrl", null, 3000).data?.ToString(); + return result; + } } } diff --git a/SGGL/BLL/app.config b/SGGL/BLL/app.config index 11911cae..39f6fcea 100644 --- a/SGGL/BLL/app.config +++ b/SGGL/BLL/app.config @@ -61,4 +61,4 @@ - + diff --git a/SGGL/FineUIPro.Web/FakesAssemblies/ThoughtWorks.QRCode.Fakes.dll b/SGGL/FineUIPro.Web/FakesAssemblies/ThoughtWorks.QRCode.Fakes.dll index 188eedf9..5a37093a 100644 Binary files a/SGGL/FineUIPro.Web/FakesAssemblies/ThoughtWorks.QRCode.Fakes.dll and b/SGGL/FineUIPro.Web/FakesAssemblies/ThoughtWorks.QRCode.Fakes.dll differ diff --git a/SGGL/FineUIPro.Web/FakesAssemblies/ThoughtWorks.QRCode.Fakes.messages b/SGGL/FineUIPro.Web/FakesAssemblies/ThoughtWorks.QRCode.Fakes.messages index 8cf6dfbd..9d901c03 100644 --- a/SGGL/FineUIPro.Web/FakesAssemblies/ThoughtWorks.QRCode.Fakes.messages +++ b/SGGL/FineUIPro.Web/FakesAssemblies/ThoughtWorks.QRCode.Fakes.messages @@ -1,5 +1,15 @@ -G:\公司项目\五环\CNCEC_SUBQHSE_WUHUAN\SGGL\FineUIPro.Web\Fakes\ThoughtWorks.QRCode.fakes : warning : 无法为 ThoughtWorks.QRCode.Codec.Reader.Pattern.AlignmentPattern 生成存根: 类型没有对程序集可见的构造函数。构造函数本身或参数可能不可见。。 -G:\公司项目\五环\CNCEC_SUBQHSE_WUHUAN\SGGL\FineUIPro.Web\Fakes\ThoughtWorks.QRCode.fakes : warning : 无法为 ThoughtWorks.QRCode.Codec.Reader.Pattern.FinderPattern 生成存根: 类型没有对程序集可见的构造函数。构造函数本身或参数可能不可见。。 -G:\公司项目\五环\CNCEC_SUBQHSE_WUHUAN\SGGL\FineUIPro.Web\Fakes\ThoughtWorks.QRCode.fakes : warning : 无法为 ThoughtWorks.QRCode.Geom.SamplingGrid+AreaGrid 生成填充码: 类型对 exported or assembly(ThoughtWorks.QRCode.Fakes) 不可见。 -G:\公司项目\五环\CNCEC_SUBQHSE_WUHUAN\SGGL\FineUIPro.Web\Fakes\ThoughtWorks.QRCode.fakes : warning : 无法为 ThoughtWorks.QRCode.Codec.QRCodeDecoder+DecodeResult 生成填充码: 类型对 exported or assembly(ThoughtWorks.QRCode.Fakes) 不可见。 -G:\公司项目\五环\CNCEC_SUBQHSE_WUHUAN\SGGL\FineUIPro.Web\Fakes\ThoughtWorks.QRCode.fakes : warning : 无法为 ThoughtWorks.QRCode.Codec.Reader.QRCodeImageReader+ModulePitch 生成填充码: 类型对 exported or assembly(ThoughtWorks.QRCode.Fakes) 不可见。 +D:\工作\五环\CNCEC_SUBQHSE_WUHUAN\SGGL\FineUIPro.Web\Fakes\ThoughtWorks.QRCode.fakes : warning : 无法为 ThoughtWorks.QRCode.Properties.Resources 生成存根: 类型对 exported or assembly(ThoughtWorks.QRCode.Fakes) 不可见。 +D:\工作\五环\CNCEC_SUBQHSE_WUHUAN\SGGL\FineUIPro.Web\Fakes\ThoughtWorks.QRCode.fakes : warning : 无法为 ThoughtWorks.QRCode.Codec.Reader.Pattern.AlignmentPattern 生成存根: 类型没有系列可见的构造函数。 +D:\工作\五环\CNCEC_SUBQHSE_WUHUAN\SGGL\FineUIPro.Web\Fakes\ThoughtWorks.QRCode.fakes : warning : 无法为 ThoughtWorks.QRCode.Codec.Util.Color_Fields 生成存根: 类型是一个值类型。 +D:\工作\五环\CNCEC_SUBQHSE_WUHUAN\SGGL\FineUIPro.Web\Fakes\ThoughtWorks.QRCode.fakes : warning : 无法为 ThoughtWorks.QRCode.Codec.Reader.Pattern.FinderPattern 生成存根: 类型没有系列可见的构造函数。 +D:\工作\五环\CNCEC_SUBQHSE_WUHUAN\SGGL\FineUIPro.Web\Fakes\ThoughtWorks.QRCode.fakes : warning : 无法为 {09D8BC6E-02EC-4FA4-99BD-B668F38E6DC6} 生成存根: 类型不受支持,因为存在内部限制。 +D:\工作\五环\CNCEC_SUBQHSE_WUHUAN\SGGL\FineUIPro.Web\Fakes\ThoughtWorks.QRCode.fakes : warning : 无法为 ThoughtWorks.QRCode.Codec.Util.DebugCanvas 生成填充码: 类型是一个接口。 +D:\工作\五环\CNCEC_SUBQHSE_WUHUAN\SGGL\FineUIPro.Web\Fakes\ThoughtWorks.QRCode.fakes : warning : 无法为 ThoughtWorks.QRCode.Geom.SamplingGrid+AreaGrid 生成填充码: 类型对 exported or assembly(ThoughtWorks.QRCode.Fakes) 不可见。 +D:\工作\五环\CNCEC_SUBQHSE_WUHUAN\SGGL\FineUIPro.Web\Fakes\ThoughtWorks.QRCode.fakes : warning : 无法为 ThoughtWorks.QRCode.Codec.QRCodeDecoder+DecodeResult 生成填充码: 类型对 exported or assembly(ThoughtWorks.QRCode.Fakes) 不可见。 +D:\工作\五环\CNCEC_SUBQHSE_WUHUAN\SGGL\FineUIPro.Web\Fakes\ThoughtWorks.QRCode.fakes : warning : 无法为 ThoughtWorks.QRCode.Codec.Data.QRCodeImage 生成填充码: 类型是一个接口。 +D:\工作\五环\CNCEC_SUBQHSE_WUHUAN\SGGL\FineUIPro.Web\Fakes\ThoughtWorks.QRCode.fakes : warning : 无法为 ThoughtWorks.QRCode.Properties.Resources 生成填充码: 类型对 exported or assembly(ThoughtWorks.QRCode.Fakes) 不可见。 +D:\工作\五环\CNCEC_SUBQHSE_WUHUAN\SGGL\FineUIPro.Web\Fakes\ThoughtWorks.QRCode.fakes : warning : 无法为 ThoughtWorks.QRCode.Codec.Reader.QRCodeImageReader+ModulePitch 生成填充码: 类型对 exported or assembly(ThoughtWorks.QRCode.Fakes) 不可见。 +D:\工作\五环\CNCEC_SUBQHSE_WUHUAN\SGGL\FineUIPro.Web\Fakes\ThoughtWorks.QRCode.fakes : warning : 无法为 ThoughtWorks.QRCode.Codec.QRCodeEncoder+ENCODE_MODE 生成填充码: 类型是一个枚举。 +D:\工作\五环\CNCEC_SUBQHSE_WUHUAN\SGGL\FineUIPro.Web\Fakes\ThoughtWorks.QRCode.fakes : warning : 无法为 ThoughtWorks.QRCode.Codec.QRCodeEncoder+ERROR_CORRECTION 生成填充码: 类型是一个枚举。 +D:\工作\五环\CNCEC_SUBQHSE_WUHUAN\SGGL\FineUIPro.Web\Fakes\ThoughtWorks.QRCode.fakes : warning : 无法为 ThoughtWorks.QRCode.Codec.Util.Color 生成填充码: 类型是一个接口。 +D:\工作\五环\CNCEC_SUBQHSE_WUHUAN\SGGL\FineUIPro.Web\Fakes\ThoughtWorks.QRCode.fakes : warning : 无法为 {09D8BC6E-02EC-4FA4-99BD-B668F38E6DC6} 生成填充码: 类型不受支持,因为存在内部限制。 diff --git a/SGGL/FineUIPro.Web/File/Word/HSSE/环境监测数据接口.docx b/SGGL/FineUIPro.Web/File/Word/HSSE/环境监测数据接口.docx new file mode 100644 index 00000000..f661aa24 Binary files /dev/null and b/SGGL/FineUIPro.Web/File/Word/HSSE/环境监测数据接口.docx differ diff --git a/SGGL/FineUIPro.Web/FineUIPro.Web.csproj b/SGGL/FineUIPro.Web/FineUIPro.Web.csproj index 11c97548..08e33887 100644 --- a/SGGL/FineUIPro.Web/FineUIPro.Web.csproj +++ b/SGGL/FineUIPro.Web/FineUIPro.Web.csproj @@ -12,7 +12,7 @@ Properties FineUIPro.Web FineUIPro.Web - v4.6.2 + v4.6.1 true @@ -63,10 +63,6 @@ - - False - bin\Apache.NMS.dll - ..\packages\Apache.NMS.ActiveMQ.1.7.2\lib\net40\Apache.NMS.ActiveMQ.dll @@ -104,8 +100,7 @@ ..\FineUIPro\Reference BLL\Microsoft.QualityTools.Testing.Fakes.dll - False - bin\Newtonsoft.Json.dll + ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll ..\packages\NPOI.2.5.5\lib\net45\NPOI.dll @@ -1033,6 +1028,7 @@ + @@ -2336,6 +2332,7 @@ + @@ -11650,6 +11647,13 @@ EnvironmentalMonitoring.aspx + + EnvironmentalMonitoringApiView.aspx + ASPXCodeBehind + + + EnvironmentalMonitoringApiView.aspx + EnvironmentalMonitoringEdit.aspx ASPXCodeBehind @@ -19321,7 +19325,7 @@ - + -
+
- + - - - - - - - + + + + + + + - - - - + + + + - + - + - - - + + + - + - + - + - - + + - + - + - - - + + + - - + + - - + + - - + + - + - - + + - - + + - - - + + + - + - + - - + + - + - - - + + + - - - + + + - + - + - - + + - + - + - - - - + + + + - + - + - - + + - - + + @@ -178,26 +178,26 @@ - - - - - - + + - - + + - - + + - - + + + + + + - + \ No newline at end of file diff --git a/SGGL/FineUIPro.Web/packages.config b/SGGL/FineUIPro.Web/packages.config index 912667ad..c6950201 100644 --- a/SGGL/FineUIPro.Web/packages.config +++ b/SGGL/FineUIPro.Web/packages.config @@ -3,7 +3,7 @@ - + diff --git a/SGGL/Model/APIItem/BaseProjectItem.cs b/SGGL/Model/APIItem/BaseProjectItem.cs new file mode 100644 index 00000000..bf1001c5 --- /dev/null +++ b/SGGL/Model/APIItem/BaseProjectItem.cs @@ -0,0 +1,347 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Model +{ + /// + /// 推送项目实体类 + /// + public class BaseProjectItem + { + /// + /// 主键 + /// + public string ProjectId + { + get; + set; + } + + /// + /// 主数据项目数据id + /// + public string MasterSysId + { + get; + set; + } + + /// + /// 分公司单位 + /// + public string UnitId + { + get; + set; + } + + /// + /// 项目编码 + /// + public string ProjectCode + { + get; + set; + } + + /// + /// 项目名称 + /// + public string ProjectName + { + get; + set; + } + + /// + /// + /// + public DateTime? StartDate + { + get; + set; + } + + /// + /// + /// + public DateTime? EndDate + { + get; + set; + } + + /// + /// + /// + public string ProjectAddress + { + get; + set; + } + + /// + /// + /// + public string ShortName + { + get; + set; + } + + /// + /// + /// + public string ProjectType + { + get; + set; + } + + /// + /// + /// + public string PostCode + { + get; + set; + } + + /// + /// + /// + public string Remark + { + get; + set; + } + + /// + /// + /// + public string ProjectState + { + get; + set; + } + + /// + /// + /// + public string ContractNo + { + get; + set; + } + + /// + /// + /// + public string WorkRange + { + get; + set; + } + + /// + /// + /// + public decimal? Duration + { + get; + set; + } + + /// + /// + /// + public bool? IsUpTotalMonth + { + get; + set; + } + + /// + /// + /// + public string ProjectMainPerson + { + get; + set; + } + + /// + /// + /// + public string ProjectLiaisonPerson + { + get; + set; + } + + /// + /// + /// + public bool? IsForeign + { + get; + set; + } + + /// + /// + /// + public string FromProjectId + { + get; + set; + } + + /// + /// + /// + public string MapCoordinates + { + get; + set; + } + + /// + /// + /// + public decimal? ProjectMoney + { + get; + set; + } + + /// + /// + /// + public decimal? ConstructionMoney + { + get; + set; + } + + /// + /// + /// + public string Country + { + get; + set; + } + + /// + /// + /// + public string Province + { + get; + set; + } + + /// + /// + /// + public string City + { + get; + set; + } + + /// + /// + /// + public string Telephone + { + get; + set; + } + + /// + /// + /// + public string EnglishRemark + { + get; + set; + } + + /// + /// + /// + public bool? IsFace + { + get; + set; + } + + /// + /// + /// + public string ProjectState2 + { + get; + set; + } + + /// + /// + /// + public decimal? Progress + { + get; + set; + } + + /// + /// + /// + public string MonitorPW + { + get; + set; + } + + /// + /// + /// + public string MonitorId + { + get; + set; + } + + /// + /// + /// + public string ProjectAttribute + { + get; + set; + } + + /// + /// 集团公司Base_Unit表中的UnitId + /// + public string SourceUnitId + { + get; + set; + } + + /// + /// 社会统一信用码 + /// + public string CollCropCode + { + get; + set; + } + } +} diff --git a/SGGL/Model/APIItem/CNCEC/CNCEC_MasterData_PcEp.cs b/SGGL/Model/APIItem/CNCEC/CNCEC_MasterData_PcEp.cs new file mode 100644 index 00000000..96c5803c --- /dev/null +++ b/SGGL/Model/APIItem/CNCEC/CNCEC_MasterData_PcEp.cs @@ -0,0 +1,77 @@ +using System; + +namespace Model +{ + /// + /// 安全合规类 + /// + [Serializable] + public class CNCEC_MasterData_PcEp + { + public string SysId { get; set; } + + public string SysMender { get; set; } + + public string SysModifydate { get; set; } + + public string SysState { get; set; } + + public string SysCreatedate { get; set; } + + public string SysCreator { get; set; } + + public string PrjCode { get; set; } + + public string PrjName { get; set; } + + public string PrjContType { get; set; } + + public string PrjFinType { get; set; } + + public string PrjStatus { get; set; } + + public string PrjType { get; set; } + + public string AdOrgCode { get; set; } + + public string BlgGroup { get; set; } + + public string BlgMainPrj { get; set; } + + public string BusiArea { get; set; } + + public string CustCode { get; set; } + + public string FactBeginDate { get; set; } + + public string FactEndDate { get; set; } + + public string FinOrgCode { get; set; } + + public string GroupPrjCode { get; set; } + + public string GroupPrjName { get; set; } + + public string InitDate { get; set; } + + public string IsEnable { get; set; } + + public string IsFore { get; set; } + + public string IsIntPrj { get; set; } + + public string LocCity { get; set; } + + public string LocPro { get; set; } + + public string LocRegion { get; set; } + + public string MnStaffCode { get; set; } + + public string PlanBeginDate { get; set; } + + public string PlanEndDate { get; set; } + + public string PppPrjCalcType { get; set; } + } +} diff --git a/SGGL/Model/APIItem/CNCEC/Law_RulesRegulations.cs b/SGGL/Model/APIItem/CNCEC/Law_RulesRegulations.cs new file mode 100644 index 00000000..be7360b9 --- /dev/null +++ b/SGGL/Model/APIItem/CNCEC/Law_RulesRegulations.cs @@ -0,0 +1,196 @@ +using System.Collections.Generic; +using System; + +namespace Model +{ + public class Law_RulesRegulationsItems + { + /// + /// 生产规章制度表 + /// + + public string RulesRegulationsId + { + get; + set; + } + /// + /// 编号 + /// + + public string RulesRegulationsCode + { + get; + set; + } + /// + /// 名称 + /// + + public string RulesRegulationsName + { + get; + set; + } + /// + /// 类型 + /// + + public string RulesRegulationsTypeId + { + get; + set; + } + /// + /// 类型编号 + /// + + public string RulesRegulationsTypeCode + { + get; + set; + } + /// + /// 类型名称 + /// + + public string RulesRegulationsTypeName + { + get; + set; + } + + /// + /// 订制时间 + /// + + public DateTime? CustomDate + { + get; + set; + } + /// + /// 适用范围 + /// + + public string ApplicableScope + { + get; + set; + } + /// + /// 摘要 + /// + + public string Remark + { + get; + set; + } + /// + /// + /// + + public string CompileMan + { + get; + set; + } + /// + /// + /// + + public DateTime? CompileDate + { + get; + set; + } + /// + /// + /// + + public string AuditMan + { + get; + set; + } + /// + /// + /// + + public DateTime? AuditDate + { + get; + set; + } + /// + /// + /// + + public bool? IsPass + { + get; + set; + } + + /// + /// 单位id + /// + + public string UnitId + { + get; + set; + } + + /// + ///附件字节 + /// + + public List FileContext + { + get; + set; + } + + /// + ///附件表主键 + /// + + public string AttachFileId + { + get; + set; + } + + /// + ///对应主键 + /// + + public string ToKeyId + { + get; + set; + } + + /// + ///附件转换 + /// + + public string AttachSource + { + get; + set; + } + + /// + /// 附件路径 + /// + + public string AttachUrl + { + get; + set; + } + } +} \ No newline at end of file diff --git a/SGGL/Model/APIItem/CNCEC/NoticeOutput.cs b/SGGL/Model/APIItem/CNCEC/NoticeOutput.cs new file mode 100644 index 00000000..ea9fc6ce --- /dev/null +++ b/SGGL/Model/APIItem/CNCEC/NoticeOutput.cs @@ -0,0 +1,16 @@ +using System; + +namespace Model +{ + [Serializable] + public class NoticeOutput + { + public string NoticeId { get; set; } + public string NoticeCode { get; set; } + public string NoticeTitle { get; set; } + public string MainContent { get; set; } + public string CompileManName { get; set; } + public DateTime? CompileDate { get; set; } + public string AttachUrl { get; set; } + } +} \ No newline at end of file diff --git a/SGGL/Model/APIItem/CNCEC/SafeLawItem.cs b/SGGL/Model/APIItem/CNCEC/SafeLawItem.cs new file mode 100644 index 00000000..f7a6ba75 --- /dev/null +++ b/SGGL/Model/APIItem/CNCEC/SafeLawItem.cs @@ -0,0 +1,222 @@ +using System; + +namespace Model +{ + /// + /// 安全合规类 + /// + [Serializable] + public class SafeLawItem + { + /// + /// ID + /// + public string ID + { + get; + set; + } + /// + /// DataType 类型 + /// + public string DataType + { + get; + set; + } + /// + /// DataType 类型 + /// + public string DataTypeName + { + get; + set; + } + /// + /// 发布状态ID + /// + public string ReleaseStates + { + get; + set; + } + /// + /// 发布状态名称 + /// + public string ReleaseStatesName + { + get; + set; + } + /// + /// 名称 + /// + public string Name + { + get; + set; + } + + /// + /// 编号 + /// + public string Code + { + get; + set; + } + /// + /// 类型Id + /// + public string TypeId + { + get; + set; + } + /// + /// 类型名称 + /// + public string TypeName + { + get; + set; + } + /// + /// 发布机构 + /// + public string ReleaseUnit + { + get; + set; + } + /// + /// 发布日期 + /// + public string ApprovalDateStr + { + get; + set; + } + /// + /// 发布日期 + /// + public DateTime? ApprovalDate + { + get; + set; + } + /// + /// 生效日期 + /// + public string EffectiveDateStr + { + get; + set; + } + /// + /// 生效日期 + /// + public DateTime? EffectiveDate + { + get; + set; + } + /// + /// 废止日期 + /// + public string AbolitionDateStr + { + get; + set; + } + /// + /// 废止日期 + /// + public DateTime? AbolitionDate + { + get; + set; + } + /// + /// 替换内容 + /// + public string ReplaceInfo + { + get; + set; + } + /// + /// 内容简介及重点关注条款 + /// + public string Description + { + get; + set; + } + /// + /// 索引ID + /// + public string IndexesIds + { + get; + set; + } + /// + /// 索引名称 + /// + public string IndexesNames + { + get; + set; + } + /// + /// 单位ID + /// + public string UnitId + { + get; + set; + } + /// + /// 单位名称 + /// + public string UnitName + { + get; + set; + } + /// + /// 上传人 + /// + public string CompileManName + { + get; + set; + } + /// + /// 上传时间 + /// + public string CompileDateStr + { + get; + set; + } + /// + /// 上传时间 + /// + public DateTime? CompileDate + { + get; + set; + } + + /// + /// 附件路径 + /// + public string AttachUrl + { + get; + set; + } + } +} diff --git a/SGGL/Model/APIItem/EnvironmentalCheckInput.cs b/SGGL/Model/APIItem/EnvironmentalCheckInput.cs new file mode 100644 index 00000000..f13bf6ce --- /dev/null +++ b/SGGL/Model/APIItem/EnvironmentalCheckInput.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Model +{ + /// + /// 环境监测 + /// + public class EnvironmentalCheckInput + { + /// + /// 项目id + /// + [Required(ErrorMessage = "ProjectId is required.")] + public string ProjectId { get; set; } + /// + /// /TSP + /// + [Required(ErrorMessage = "Tsp is required.")] + public double Tsp { get; set; } + /// + /// 温度 + /// + [Required(ErrorMessage = "Temp is required.")] + public double Temp { get; set; } + /// + /// 噪声 + /// + [Required(ErrorMessage = "Noise is required.")] + public double Noise { get; set; } + /// + /// 湿度 + /// + [Required(ErrorMessage = "Humid is required.")] + public double Humid { get; set; } + /// + /// PM2.5 + /// + [Required(ErrorMessage = "PmTwoPointFive is required.")] + public double PmTwoPointFive { get; set; } + /// + /// 风速 + /// + [Required(ErrorMessage = "WindSpeed is required.")] + public double WindSpeed { get; set; } + /// + /// PM10 + /// + [Required(ErrorMessage = "PmTen is required.")] + public double PmTen { get; set; } + /// + /// 监测时间 + /// + [Required(ErrorMessage = "Time is required.")] + public DateTime Time { get; set; } + /// + /// 创建时间 + /// + public DateTime? CreateTime { get; set; } + } +} diff --git a/SGGL/Model/Model.cs b/SGGL/Model/Model.cs index 2049c257..debdf65a 100644 --- a/SGGL/Model/Model.cs +++ b/SGGL/Model/Model.cs @@ -941,6 +941,9 @@ namespace Model partial void InsertEnvironmental_UnexpectedEnvironmental(Environmental_UnexpectedEnvironmental instance); partial void UpdateEnvironmental_UnexpectedEnvironmental(Environmental_UnexpectedEnvironmental instance); partial void DeleteEnvironmental_UnexpectedEnvironmental(Environmental_UnexpectedEnvironmental instance); + partial void InsertEnvironmentalCheck(EnvironmentalCheck instance); + partial void UpdateEnvironmentalCheck(EnvironmentalCheck instance); + partial void DeleteEnvironmentalCheck(EnvironmentalCheck instance); partial void InsertExchange_Content(Exchange_Content instance); partial void UpdateExchange_Content(Exchange_Content instance); partial void DeleteExchange_Content(Exchange_Content instance); @@ -1364,6 +1367,9 @@ namespace Model partial void InsertJDGL_UndergroundPipeCompletion(JDGL_UndergroundPipeCompletion instance); partial void UpdateJDGL_UndergroundPipeCompletion(JDGL_UndergroundPipeCompletion instance); partial void DeleteJDGL_UndergroundPipeCompletion(JDGL_UndergroundPipeCompletion instance); + partial void InsertJDGL_WBS(JDGL_WBS instance); + partial void UpdateJDGL_WBS(JDGL_WBS instance); + partial void DeleteJDGL_WBS(JDGL_WBS instance); partial void InsertJDGL_WeekPlan(JDGL_WeekPlan instance); partial void UpdateJDGL_WeekPlan(JDGL_WeekPlan instance); partial void DeleteJDGL_WeekPlan(JDGL_WeekPlan instance); @@ -5199,6 +5205,14 @@ namespace Model } } + public System.Data.Linq.Table EnvironmentalCheck + { + get + { + return this.GetTable(); + } + } + public System.Data.Linq.Table Exchange_Content { get @@ -6335,6 +6349,14 @@ namespace Model } } + public System.Data.Linq.Table JDGL_WBS + { + get + { + return this.GetTable(); + } + } + public System.Data.Linq.Table JDGL_WeekPlan { get @@ -26337,6 +26359,10 @@ namespace Model private string _MonitorId; + private string _MasterSysId; + + private System.Nullable _IsDelete; + private EntitySet _Accident_AccidentHandle; private EntitySet _Accident_AccidentPersonRecord; @@ -27035,6 +27061,10 @@ namespace Model partial void OnMonitorPWChanged(); partial void OnMonitorIdChanging(string value); partial void OnMonitorIdChanged(); + partial void OnMasterSysIdChanging(string value); + partial void OnMasterSysIdChanged(); + partial void OnIsDeleteChanging(System.Nullable value); + partial void OnIsDeleteChanged(); #endregion public Base_Project() @@ -28157,6 +28187,46 @@ namespace Model } } + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_MasterSysId", DbType="NVarChar(200)")] + public string MasterSysId + { + get + { + return this._MasterSysId; + } + set + { + if ((this._MasterSysId != value)) + { + this.OnMasterSysIdChanging(value); + this.SendPropertyChanging(); + this._MasterSysId = value; + this.SendPropertyChanged("MasterSysId"); + this.OnMasterSysIdChanged(); + } + } + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_IsDelete", DbType="Bit")] + public System.Nullable IsDelete + { + get + { + return this._IsDelete; + } + set + { + if ((this._IsDelete != value)) + { + this.OnIsDeleteChanging(value); + this.SendPropertyChanging(); + this._IsDelete = value; + this.SendPropertyChanged("IsDelete"); + this.OnIsDeleteChanged(); + } + } + } + [global::System.Data.Linq.Mapping.AssociationAttribute(Name="FK_Accident_AccidentHandle_Base_Project", Storage="_Accident_AccidentHandle", ThisKey="ProjectId", OtherKey="ProjectId", DeleteRule="NO ACTION")] public EntitySet Accident_AccidentHandle { @@ -96564,7 +96634,7 @@ namespace Model } } - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_CertificateNumber", DbType="NVarChar(50)")] + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_CertificateNumber", DbType="NVarChar(500)")] public string CertificateNumber { get @@ -105290,6 +105360,8 @@ namespace Model private System.Nullable _ApproveDate; + private System.Nullable _Extract; + private EntityRef _Base_Project; private EntityRef _Base_Unit; @@ -105326,6 +105398,8 @@ namespace Model partial void OnApproveManChanged(); partial void OnApproveDateChanging(System.Nullable value); partial void OnApproveDateChanged(); + partial void OnExtractChanging(System.Nullable value); + partial void OnExtractChanged(); #endregion public CostGoods_CostSmallDetail() @@ -105604,6 +105678,26 @@ namespace Model } } + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Extract", DbType="Decimal(18,0)")] + public System.Nullable Extract + { + get + { + return this._Extract; + } + set + { + if ((this._Extract != value)) + { + this.OnExtractChanging(value); + this.SendPropertyChanging(); + this._Extract = value; + this.SendPropertyChanged("Extract"); + this.OnExtractChanged(); + } + } + } + [global::System.Data.Linq.Mapping.AssociationAttribute(Name="FK_CostGoods_CostSmallDetail_Base_Project", Storage="_Base_Project", ThisKey="ProjectId", OtherKey="ProjectId", IsForeignKey=true)] public Base_Project Base_Project { @@ -150411,6 +150505,332 @@ namespace Model } } + [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.EnvironmentalCheck")] + public partial class EnvironmentalCheck : INotifyPropertyChanging, INotifyPropertyChanged + { + + private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty); + + private string _Id; + + private string _ProjectId; + + private System.Nullable _Tsp; + + private System.Nullable _Temp; + + private System.Nullable _Noise; + + private System.Nullable _Humid; + + private System.Nullable _PmTwoPointFive; + + private System.Nullable _WindSpeed; + + private System.Nullable _PmTen; + + private System.Nullable _Time; + + private System.Nullable _CreateTime; + + private System.Nullable _IsPushed; + + #region 可扩展性方法定义 + partial void OnLoaded(); + partial void OnValidate(System.Data.Linq.ChangeAction action); + partial void OnCreated(); + partial void OnIdChanging(string value); + partial void OnIdChanged(); + partial void OnProjectIdChanging(string value); + partial void OnProjectIdChanged(); + partial void OnTspChanging(System.Nullable value); + partial void OnTspChanged(); + partial void OnTempChanging(System.Nullable value); + partial void OnTempChanged(); + partial void OnNoiseChanging(System.Nullable value); + partial void OnNoiseChanged(); + partial void OnHumidChanging(System.Nullable value); + partial void OnHumidChanged(); + partial void OnPmTwoPointFiveChanging(System.Nullable value); + partial void OnPmTwoPointFiveChanged(); + partial void OnWindSpeedChanging(System.Nullable value); + partial void OnWindSpeedChanged(); + partial void OnPmTenChanging(System.Nullable value); + partial void OnPmTenChanged(); + partial void OnTimeChanging(System.Nullable value); + partial void OnTimeChanged(); + partial void OnCreateTimeChanging(System.Nullable value); + partial void OnCreateTimeChanged(); + partial void OnIsPushedChanging(System.Nullable value); + partial void OnIsPushedChanged(); + #endregion + + public EnvironmentalCheck() + { + OnCreated(); + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Id", DbType="NVarChar(50) NOT NULL", CanBeNull=false, IsPrimaryKey=true)] + public string Id + { + get + { + return this._Id; + } + set + { + if ((this._Id != value)) + { + this.OnIdChanging(value); + this.SendPropertyChanging(); + this._Id = value; + this.SendPropertyChanged("Id"); + this.OnIdChanged(); + } + } + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ProjectId", DbType="NVarChar(50)")] + public string ProjectId + { + get + { + return this._ProjectId; + } + set + { + if ((this._ProjectId != value)) + { + this.OnProjectIdChanging(value); + this.SendPropertyChanging(); + this._ProjectId = value; + this.SendPropertyChanged("ProjectId"); + this.OnProjectIdChanged(); + } + } + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Tsp", DbType="Float")] + public System.Nullable Tsp + { + get + { + return this._Tsp; + } + set + { + if ((this._Tsp != value)) + { + this.OnTspChanging(value); + this.SendPropertyChanging(); + this._Tsp = value; + this.SendPropertyChanged("Tsp"); + this.OnTspChanged(); + } + } + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Temp", DbType="Float")] + public System.Nullable Temp + { + get + { + return this._Temp; + } + set + { + if ((this._Temp != value)) + { + this.OnTempChanging(value); + this.SendPropertyChanging(); + this._Temp = value; + this.SendPropertyChanged("Temp"); + this.OnTempChanged(); + } + } + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Noise", DbType="Float")] + public System.Nullable Noise + { + get + { + return this._Noise; + } + set + { + if ((this._Noise != value)) + { + this.OnNoiseChanging(value); + this.SendPropertyChanging(); + this._Noise = value; + this.SendPropertyChanged("Noise"); + this.OnNoiseChanged(); + } + } + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Humid", DbType="Float")] + public System.Nullable Humid + { + get + { + return this._Humid; + } + set + { + if ((this._Humid != value)) + { + this.OnHumidChanging(value); + this.SendPropertyChanging(); + this._Humid = value; + this.SendPropertyChanged("Humid"); + this.OnHumidChanged(); + } + } + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_PmTwoPointFive", DbType="Float")] + public System.Nullable PmTwoPointFive + { + get + { + return this._PmTwoPointFive; + } + set + { + if ((this._PmTwoPointFive != value)) + { + this.OnPmTwoPointFiveChanging(value); + this.SendPropertyChanging(); + this._PmTwoPointFive = value; + this.SendPropertyChanged("PmTwoPointFive"); + this.OnPmTwoPointFiveChanged(); + } + } + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_WindSpeed", DbType="Float")] + public System.Nullable WindSpeed + { + get + { + return this._WindSpeed; + } + set + { + if ((this._WindSpeed != value)) + { + this.OnWindSpeedChanging(value); + this.SendPropertyChanging(); + this._WindSpeed = value; + this.SendPropertyChanged("WindSpeed"); + this.OnWindSpeedChanged(); + } + } + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_PmTen", DbType="Float")] + public System.Nullable PmTen + { + get + { + return this._PmTen; + } + set + { + if ((this._PmTen != value)) + { + this.OnPmTenChanging(value); + this.SendPropertyChanging(); + this._PmTen = value; + this.SendPropertyChanged("PmTen"); + this.OnPmTenChanged(); + } + } + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Time", DbType="DateTime")] + public System.Nullable Time + { + get + { + return this._Time; + } + set + { + if ((this._Time != value)) + { + this.OnTimeChanging(value); + this.SendPropertyChanging(); + this._Time = value; + this.SendPropertyChanged("Time"); + this.OnTimeChanged(); + } + } + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_CreateTime", DbType="DateTime")] + public System.Nullable CreateTime + { + get + { + return this._CreateTime; + } + set + { + if ((this._CreateTime != value)) + { + this.OnCreateTimeChanging(value); + this.SendPropertyChanging(); + this._CreateTime = value; + this.SendPropertyChanged("CreateTime"); + this.OnCreateTimeChanged(); + } + } + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_IsPushed", DbType="Bit")] + public System.Nullable IsPushed + { + get + { + return this._IsPushed; + } + set + { + if ((this._IsPushed != value)) + { + this.OnIsPushedChanging(value); + this.SendPropertyChanging(); + this._IsPushed = value; + this.SendPropertyChanged("IsPushed"); + this.OnIsPushedChanged(); + } + } + } + + public event PropertyChangingEventHandler PropertyChanging; + + public event PropertyChangedEventHandler PropertyChanged; + + protected virtual void SendPropertyChanging() + { + if ((this.PropertyChanging != null)) + { + this.PropertyChanging(this, emptyChangingEventArgs); + } + } + + protected virtual void SendPropertyChanged(String propertyName) + { + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); + } + } + } + [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.Exchange_Content")] public partial class Exchange_Content : INotifyPropertyChanging, INotifyPropertyChanged { @@ -178636,6 +179056,8 @@ namespace Model private System.Nullable _CreateDate; + private System.Nullable _EnvironmentalTrainNum; + #region 可扩展性方法定义 partial void OnLoaded(); partial void OnValidate(System.Data.Linq.ChangeAction action); @@ -178796,6 +179218,8 @@ namespace Model partial void OnCreateManChanged(); partial void OnCreateDateChanging(System.Nullable value); partial void OnCreateDateChanged(); + partial void OnEnvironmentalTrainNumChanging(System.Nullable value); + partial void OnEnvironmentalTrainNumChanged(); #endregion public HSSEData_HSSE() @@ -180363,6 +180787,26 @@ namespace Model } } + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_EnvironmentalTrainNum", DbType="Int")] + public System.Nullable EnvironmentalTrainNum + { + get + { + return this._EnvironmentalTrainNum; + } + set + { + if ((this._EnvironmentalTrainNum != value)) + { + this.OnEnvironmentalTrainNumChanging(value); + this.SendPropertyChanging(); + this._EnvironmentalTrainNum = value; + this.SendPropertyChanged("EnvironmentalTrainNum"); + this.OnEnvironmentalTrainNumChanged(); + } + } + } + public event PropertyChangingEventHandler PropertyChanging; public event PropertyChangedEventHandler PropertyChanged; @@ -218786,6 +219230,333 @@ namespace Model } } + [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.JDGL_WBS")] + public partial class JDGL_WBS : INotifyPropertyChanging, INotifyPropertyChanged + { + + private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty); + + private string _Id; + + private string _ProjectId; + + private string _ParentId; + + private string _ItemName; + + private string _ItemNum; + + private System.Nullable _PlanStart; + + private System.Nullable _PlanEnd; + + private System.Nullable _RealityEnd; + + private string _PathCode; + + private EntityRef _JDGL_WBS_JDGL_WBS; + + private EntityRef _JDGL_WBS_JDGL_WBS1; + + #region 可扩展性方法定义 + partial void OnLoaded(); + partial void OnValidate(System.Data.Linq.ChangeAction action); + partial void OnCreated(); + partial void OnIdChanging(string value); + partial void OnIdChanged(); + partial void OnProjectIdChanging(string value); + partial void OnProjectIdChanged(); + partial void OnParentIdChanging(string value); + partial void OnParentIdChanged(); + partial void OnItemNameChanging(string value); + partial void OnItemNameChanged(); + partial void OnItemNumChanging(string value); + partial void OnItemNumChanged(); + partial void OnPlanStartChanging(System.Nullable value); + partial void OnPlanStartChanged(); + partial void OnPlanEndChanging(System.Nullable value); + partial void OnPlanEndChanged(); + partial void OnRealityEndChanging(System.Nullable value); + partial void OnRealityEndChanged(); + partial void OnPathCodeChanging(string value); + partial void OnPathCodeChanged(); + #endregion + + public JDGL_WBS() + { + this._JDGL_WBS_JDGL_WBS = default(EntityRef); + this._JDGL_WBS_JDGL_WBS1 = default(EntityRef); + OnCreated(); + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Id", DbType="NVarChar(50) NOT NULL", CanBeNull=false, IsPrimaryKey=true)] + public string Id + { + get + { + return this._Id; + } + set + { + if ((this._Id != value)) + { + if (this._JDGL_WBS_JDGL_WBS.HasLoadedOrAssignedValue) + { + throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException(); + } + this.OnIdChanging(value); + this.SendPropertyChanging(); + this._Id = value; + this.SendPropertyChanged("Id"); + this.OnIdChanged(); + } + } + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ProjectId", DbType="NVarChar(50)")] + public string ProjectId + { + get + { + return this._ProjectId; + } + set + { + if ((this._ProjectId != value)) + { + this.OnProjectIdChanging(value); + this.SendPropertyChanging(); + this._ProjectId = value; + this.SendPropertyChanged("ProjectId"); + this.OnProjectIdChanged(); + } + } + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ParentId", DbType="NVarChar(50)")] + public string ParentId + { + get + { + return this._ParentId; + } + set + { + if ((this._ParentId != value)) + { + this.OnParentIdChanging(value); + this.SendPropertyChanging(); + this._ParentId = value; + this.SendPropertyChanged("ParentId"); + this.OnParentIdChanged(); + } + } + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ItemName", DbType="NVarChar(50)")] + public string ItemName + { + get + { + return this._ItemName; + } + set + { + if ((this._ItemName != value)) + { + this.OnItemNameChanging(value); + this.SendPropertyChanging(); + this._ItemName = value; + this.SendPropertyChanged("ItemName"); + this.OnItemNameChanged(); + } + } + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ItemNum", DbType="NVarChar(50)")] + public string ItemNum + { + get + { + return this._ItemNum; + } + set + { + if ((this._ItemNum != value)) + { + this.OnItemNumChanging(value); + this.SendPropertyChanging(); + this._ItemNum = value; + this.SendPropertyChanged("ItemNum"); + this.OnItemNumChanged(); + } + } + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_PlanStart", DbType="DateTime")] + public System.Nullable PlanStart + { + get + { + return this._PlanStart; + } + set + { + if ((this._PlanStart != value)) + { + this.OnPlanStartChanging(value); + this.SendPropertyChanging(); + this._PlanStart = value; + this.SendPropertyChanged("PlanStart"); + this.OnPlanStartChanged(); + } + } + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_PlanEnd", DbType="DateTime")] + public System.Nullable PlanEnd + { + get + { + return this._PlanEnd; + } + set + { + if ((this._PlanEnd != value)) + { + this.OnPlanEndChanging(value); + this.SendPropertyChanging(); + this._PlanEnd = value; + this.SendPropertyChanged("PlanEnd"); + this.OnPlanEndChanged(); + } + } + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_RealityEnd", DbType="DateTime")] + public System.Nullable RealityEnd + { + get + { + return this._RealityEnd; + } + set + { + if ((this._RealityEnd != value)) + { + this.OnRealityEndChanging(value); + this.SendPropertyChanging(); + this._RealityEnd = value; + this.SendPropertyChanged("RealityEnd"); + this.OnRealityEndChanged(); + } + } + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_PathCode", DbType="NVarChar(50)")] + public string PathCode + { + get + { + return this._PathCode; + } + set + { + if ((this._PathCode != value)) + { + this.OnPathCodeChanging(value); + this.SendPropertyChanging(); + this._PathCode = value; + this.SendPropertyChanged("PathCode"); + this.OnPathCodeChanged(); + } + } + } + + [global::System.Data.Linq.Mapping.AssociationAttribute(Name="FK_JDGL_WBS_JDGL_WBS", Storage="_JDGL_WBS_JDGL_WBS", ThisKey="Id", OtherKey="Id", IsForeignKey=true)] + public JDGL_WBS JDGL_WBS_JDGL_WBS + { + get + { + return this._JDGL_WBS_JDGL_WBS.Entity; + } + set + { + JDGL_WBS previousValue = this._JDGL_WBS_JDGL_WBS.Entity; + if (((previousValue != value) + || (this._JDGL_WBS_JDGL_WBS.HasLoadedOrAssignedValue == false))) + { + this.SendPropertyChanging(); + if ((previousValue != null)) + { + this._JDGL_WBS_JDGL_WBS.Entity = null; + previousValue.JDGL_WBS_JDGL_WBS1 = null; + } + this._JDGL_WBS_JDGL_WBS.Entity = value; + if ((value != null)) + { + value.JDGL_WBS_JDGL_WBS1 = this; + this._Id = value.Id; + } + else + { + this._Id = default(string); + } + this.SendPropertyChanged("JDGL_WBS_JDGL_WBS"); + } + } + } + + [global::System.Data.Linq.Mapping.AssociationAttribute(Name="FK_JDGL_WBS_JDGL_WBS", Storage="_JDGL_WBS_JDGL_WBS1", ThisKey="Id", OtherKey="Id", IsUnique=true, IsForeignKey=false, DeleteRule="NO ACTION")] + public JDGL_WBS JDGL_WBS_JDGL_WBS1 + { + get + { + return this._JDGL_WBS_JDGL_WBS1.Entity; + } + set + { + JDGL_WBS previousValue = this._JDGL_WBS_JDGL_WBS1.Entity; + if (((previousValue != value) + || (this._JDGL_WBS_JDGL_WBS1.HasLoadedOrAssignedValue == false))) + { + this.SendPropertyChanging(); + if ((previousValue != null)) + { + this._JDGL_WBS_JDGL_WBS1.Entity = null; + previousValue.JDGL_WBS_JDGL_WBS = null; + } + this._JDGL_WBS_JDGL_WBS1.Entity = value; + if ((value != null)) + { + value.JDGL_WBS_JDGL_WBS = this; + } + this.SendPropertyChanged("JDGL_WBS_JDGL_WBS1"); + } + } + } + + public event PropertyChangingEventHandler PropertyChanging; + + public event PropertyChangedEventHandler PropertyChanged; + + protected virtual void SendPropertyChanging() + { + if ((this.PropertyChanging != null)) + { + this.PropertyChanging(this, emptyChangingEventArgs); + } + } + + protected virtual void SendPropertyChanged(String propertyName) + { + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); + } + } + } + [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.JDGL_WeekPlan")] public partial class JDGL_WeekPlan : INotifyPropertyChanging, INotifyPropertyChanged { @@ -259992,6 +260763,10 @@ namespace Model private string _MeetingHostManOther; + private string _ProjectId; + + private string _UnitId; + #region 可扩展性方法定义 partial void OnLoaded(); partial void OnValidate(System.Data.Linq.ChangeAction action); @@ -260026,6 +260801,10 @@ namespace Model partial void OnAttentPersonIdsChanged(); partial void OnMeetingHostManOtherChanging(string value); partial void OnMeetingHostManOtherChanged(); + partial void OnProjectIdChanging(string value); + partial void OnProjectIdChanged(); + partial void OnUnitIdChanging(string value); + partial void OnUnitIdChanged(); #endregion public Meeting_CompanySafetyMeeting() @@ -260333,6 +261112,46 @@ namespace Model } } + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ProjectId", DbType="NVarChar(50)")] + public string ProjectId + { + get + { + return this._ProjectId; + } + set + { + if ((this._ProjectId != value)) + { + this.OnProjectIdChanging(value); + this.SendPropertyChanging(); + this._ProjectId = value; + this.SendPropertyChanged("ProjectId"); + this.OnProjectIdChanged(); + } + } + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_UnitId", DbType="NVarChar(50)")] + public string UnitId + { + get + { + return this._UnitId; + } + set + { + if ((this._UnitId != value)) + { + this.OnUnitIdChanging(value); + this.SendPropertyChanging(); + this._UnitId = value; + this.SendPropertyChanged("UnitId"); + this.OnUnitIdChanged(); + } + } + } + public event PropertyChangingEventHandler PropertyChanging; public event PropertyChangedEventHandler PropertyChanged; @@ -260390,6 +261209,8 @@ namespace Model private string _MeetingHostManOther; + private string _UnitId; + #region 可扩展性方法定义 partial void OnLoaded(); partial void OnValidate(System.Data.Linq.ChangeAction action); @@ -260424,6 +261245,8 @@ namespace Model partial void OnAttentPersonIdsChanged(); partial void OnMeetingHostManOtherChanging(string value); partial void OnMeetingHostManOtherChanged(); + partial void OnUnitIdChanging(string value); + partial void OnUnitIdChanged(); #endregion public Meeting_CompanySpecialMeeting() @@ -260731,6 +261554,26 @@ namespace Model } } + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_UnitId", DbType="NVarChar(50)")] + public string UnitId + { + get + { + return this._UnitId; + } + set + { + if ((this._UnitId != value)) + { + this.OnUnitIdChanging(value); + this.SendPropertyChanging(); + this._UnitId = value; + this.SendPropertyChanged("UnitId"); + this.OnUnitIdChanged(); + } + } + } + public event PropertyChangingEventHandler PropertyChanging; public event PropertyChangedEventHandler PropertyChanged; @@ -298076,6 +298919,8 @@ namespace Model private System.Nullable _SuperFinishedNum; + private System.Nullable _EnvironmentalTrainNum; + #region 可扩展性方法定义 partial void OnLoaded(); partial void OnValidate(System.Data.Linq.ChangeAction action); @@ -298232,6 +299077,8 @@ namespace Model partial void OnSuperConstructionNumChanged(); partial void OnSuperFinishedNumChanging(System.Nullable value); partial void OnSuperFinishedNumChanged(); + partial void OnEnvironmentalTrainNumChanging(System.Nullable value); + partial void OnEnvironmentalTrainNumChanged(); #endregion public Project_HSSEData_HSSE() @@ -299759,6 +300606,26 @@ namespace Model } } + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_EnvironmentalTrainNum", DbType="Int")] + public System.Nullable EnvironmentalTrainNum + { + get + { + return this._EnvironmentalTrainNum; + } + set + { + if ((this._EnvironmentalTrainNum != value)) + { + this.OnEnvironmentalTrainNumChanging(value); + this.SendPropertyChanging(); + this._EnvironmentalTrainNum = value; + this.SendPropertyChanged("EnvironmentalTrainNum"); + this.OnEnvironmentalTrainNumChanged(); + } + } + } + public event PropertyChangingEventHandler PropertyChanging; public event PropertyChangedEventHandler PropertyChanged; @@ -314918,6 +315785,8 @@ namespace Model private string _States; + private string _UserId; + private EntityRef _Base_Certificate; private EntityRef _SitePerson_Person; @@ -314966,6 +315835,8 @@ namespace Model partial void OnAuditOpinionChanged(); partial void OnStatesChanging(string value); partial void OnStatesChanged(); + partial void OnUserIdChanging(string value); + partial void OnUserIdChanged(); #endregion public QualityAudit_PersonQuality() @@ -315353,6 +316224,26 @@ namespace Model } } + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_UserId", DbType="NVarChar(50)")] + public string UserId + { + get + { + return this._UserId; + } + set + { + if ((this._UserId != value)) + { + this.OnUserIdChanging(value); + this.SendPropertyChanging(); + this._UserId = value; + this.SendPropertyChanged("UserId"); + this.OnUserIdChanged(); + } + } + } + [global::System.Data.Linq.Mapping.AssociationAttribute(Name="FK_QualityAudit_PersonQuality_Base_Certificate", Storage="_Base_Certificate", ThisKey="CertificateId", OtherKey="CertificateId", IsForeignKey=true)] public Base_Certificate Base_Certificate { diff --git a/SGGL/Model/Model.csproj b/SGGL/Model/Model.csproj index 0fdf0a15..843a4945 100644 --- a/SGGL/Model/Model.csproj +++ b/SGGL/Model/Model.csproj @@ -10,7 +10,7 @@ Properties Model Model - v4.6.2 + v4.6.1 512 @@ -47,6 +47,10 @@ ..\packages\Newtonsoft.Json.12.0.1\lib\net40\Newtonsoft.Json.dll + + ..\packages\System.ComponentModel.Annotations.5.0.0\lib\net461\System.ComponentModel.Annotations.dll + + @@ -64,11 +68,16 @@ + + + + + @@ -78,6 +87,7 @@ + @@ -232,12 +242,29 @@ + + + + + + + + + + + + + + + - + + + - - - - + + + + - + - + - + - + - - - + + + - + - + - + - + - - + + - - - + + + - - - - + + + + - - - + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + \ No newline at end of file diff --git a/SGGL/WebAPI/WebAPI.csproj b/SGGL/WebAPI/WebAPI.csproj index 84dec93a..9c0dbbb1 100644 --- a/SGGL/WebAPI/WebAPI.csproj +++ b/SGGL/WebAPI/WebAPI.csproj @@ -14,7 +14,7 @@ Properties WebAPI WebAPI - v4.6.2 + v4.6.1 false true @@ -50,8 +50,9 @@ bin\WebAPI.xml - - ..\FineUIPro\Reference BLL\Aspose.Words.dll + + False + bin\Aspose.Words.dll @@ -77,7 +78,6 @@ - ..\packages\Microsoft.AspNet.WebApi.Core.5.2.7\lib\net45\System.Web.Http.dll @@ -126,7 +126,6 @@ True ..\packages\Microsoft.AspNet.WebPages.3.2.4\lib\net45\System.Web.WebPages.Razor.dll - ..\packages\WebActivatorEx.2.0\lib\net40\WebActivatorEx.dll @@ -158,6 +157,7 @@ + diff --git a/SGGL/WebAPI/WebAPI.csproj.user b/SGGL/WebAPI/WebAPI.csproj.user index 71396b97..c9ab4ef5 100644 --- a/SGGL/WebAPI/WebAPI.csproj.user +++ b/SGGL/WebAPI/WebAPI.csproj.user @@ -1,7 +1,7 @@  - Debug|Any CPU + Release|Any CPU true @@ -9,7 +9,7 @@ - G:\公司项目\五环\CNCEC_SUBQHSE_WUHUAN\SGGL\WebAPI\Properties\PublishProfiles\FolderProfile.pubxml + FolderProfile MvcControllerEmptyScaffolder root/Common/MVC/Controller 600 diff --git a/SGGL/WebAPI/packages.config b/SGGL/WebAPI/packages.config index d3dda5e0..332fd67f 100644 --- a/SGGL/WebAPI/packages.config +++ b/SGGL/WebAPI/packages.config @@ -27,6 +27,7 @@ + \ No newline at end of file