| 
									
										
										
										
											2025-03-07 16:30:12 +08:00
										 |  |  |  | using BLL; | 
					
						
							|  |  |  |  | using System; | 
					
						
							|  |  |  |  | using System.Linq; | 
					
						
							|  |  |  |  | using System.Web.Http; | 
					
						
							|  |  |  |  | using BLL.OfficeCheck.Inspect; | 
					
						
							|  |  |  |  | using Model; | 
					
						
							|  |  |  |  | using static BLL.OfficeCheck.Inspect.Inspect_InspectionService; | 
					
						
							|  |  |  |  | using System.Collections.Generic; | 
					
						
							| 
									
										
										
										
											2025-03-30 17:13:19 +08:00
										 |  |  |  | using static WebAPI.Controllers.HSSE.ImageRecognitionController; | 
					
						
							| 
									
										
										
										
											2025-04-06 23:26:22 +08:00
										 |  |  |  | using Microsoft.Office.Interop.Word; | 
					
						
							| 
									
										
										
										
											2025-03-07 16:30:12 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace WebAPI.Controllers.HSSE | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     public class SafetyInspectionController : ApiController | 
					
						
							|  |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2025-04-06 23:26:22 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 保存专检主项 | 
					
						
							| 
									
										
										
										
											2025-03-07 16:30:12 +08:00
										 |  |  |  |         [HttpPost] | 
					
						
							| 
									
										
										
										
											2025-04-06 23:26:22 +08:00
										 |  |  |  |         public Model.ResponeData SaveInspection(Model.Inspect_Inspection inspection) | 
					
						
							| 
									
										
										
										
											2025-03-07 16:30:12 +08:00
										 |  |  |  |         { | 
					
						
							|  |  |  |  |             var responeData = new Model.ResponeData(); | 
					
						
							|  |  |  |  |             try | 
					
						
							|  |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2025-04-06 23:26:22 +08:00
										 |  |  |  |                 Model.Inspect_Inspection obj = new Model.Inspect_Inspection(); | 
					
						
							|  |  |  |  |                 if (inspection.InspectionId == null) | 
					
						
							| 
									
										
										
										
											2025-03-07 16:30:12 +08:00
										 |  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2025-04-06 23:26:22 +08:00
										 |  |  |  |                     obj = Inspect_InspectionService.SaveInspection(inspection); | 
					
						
							|  |  |  |  |                      | 
					
						
							|  |  |  |  |                 }else | 
					
						
							| 
									
										
										
										
											2025-03-07 16:30:12 +08:00
										 |  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2025-04-06 23:26:22 +08:00
										 |  |  |  |                     Inspect_InspectionService.UpdateInspection(inspection); | 
					
						
							| 
									
										
										
										
											2025-03-07 16:30:12 +08:00
										 |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2025-04-06 23:26:22 +08:00
										 |  |  |  |                 responeData.data = obj.InspectionId; | 
					
						
							| 
									
										
										
										
											2025-03-07 16:30:12 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-06 23:26:22 +08:00
										 |  |  |  |             } catch (Exception ex) | 
					
						
							| 
									
										
										
										
											2025-03-07 16:30:12 +08:00
										 |  |  |  |             { | 
					
						
							|  |  |  |  |                 responeData.code = 0; | 
					
						
							|  |  |  |  |                 responeData.message = ex.Message; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return responeData; | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2025-04-06 23:26:22 +08:00
										 |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-07 16:30:12 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-06 23:26:22 +08:00
										 |  |  |  |         #region 获取专检主项详细 | 
					
						
							|  |  |  |  |         public Model.ResponeData getInspectionById(string InspectionId) | 
					
						
							| 
									
										
										
										
											2025-03-07 16:30:12 +08:00
										 |  |  |  |         { | 
					
						
							|  |  |  |  |             var responeData = new Model.ResponeData(); | 
					
						
							|  |  |  |  |             try | 
					
						
							|  |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2025-04-06 23:26:22 +08:00
										 |  |  |  |                 responeData.data = Inspect_InspectionService.GetInspectionById(InspectionId); | 
					
						
							| 
									
										
										
										
											2025-03-07 16:30:12 +08:00
										 |  |  |  |             } | 
					
						
							|  |  |  |  |             catch (Exception ex) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 responeData.code = 0; | 
					
						
							|  |  |  |  |                 responeData.message = ex.Message; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return responeData; | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2025-04-06 23:26:22 +08:00
										 |  |  |  |         #endregion | 
					
						
							| 
									
										
										
										
											2025-03-07 16:30:12 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-06 23:26:22 +08:00
										 |  |  |  |         #region 获取专检主项列表 | 
					
						
							| 
									
										
										
										
											2025-04-15 20:48:53 +08:00
										 |  |  |  |         public Model.ResponeData getInspectionList(string ProjectId, string States, int PageNumber, int PageSize, string type = "1") | 
					
						
							| 
									
										
										
										
											2025-03-07 16:30:12 +08:00
										 |  |  |  |         { | 
					
						
							|  |  |  |  |             var responeData = new Model.ResponeData(); | 
					
						
							|  |  |  |  |             try | 
					
						
							|  |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2025-04-15 20:48:53 +08:00
										 |  |  |  |                 responeData.data = Inspect_InspectionService.GetInspectionList(ProjectId, type, States,  PageNumber, PageSize); | 
					
						
							| 
									
										
										
										
											2025-03-07 16:30:12 +08:00
										 |  |  |  |             } | 
					
						
							|  |  |  |  |             catch (Exception ex) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 responeData.code = 0; | 
					
						
							|  |  |  |  |                 responeData.message = ex.Message; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return responeData; | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2025-04-06 23:26:22 +08:00
										 |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-30 17:13:19 +08:00
										 |  |  |  |         #region 保存专检子项 | 
					
						
							|  |  |  |  |         [HttpPost] | 
					
						
							|  |  |  |  |         public Model.ResponeData SaveInspectionChild(Model.Inspect_InspectionItem child) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             var responeData = new Model.ResponeData(); | 
					
						
							|  |  |  |  |             try | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 if (string.IsNullOrEmpty(child.InspectionItemId)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2025-04-06 23:26:22 +08:00
										 |  |  |  |                     Inspect_InspectionService.SaveInspectionItem(child); | 
					
						
							| 
									
										
										
										
											2025-03-30 17:13:19 +08:00
										 |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     Inspect_InspectionService.UpdateInspectionItem(child); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } catch (Exception ex) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 responeData.code = 0; | 
					
						
							|  |  |  |  |                 responeData.message = ex.Message; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |          | 
					
						
							| 
									
										
										
										
											2025-03-07 16:30:12 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-30 17:13:19 +08:00
										 |  |  |  |             return responeData; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							| 
									
										
										
										
											2025-04-06 23:26:22 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 获取专检子项详细 | 
					
						
							|  |  |  |  |         public Model.ResponeData getInspectItemsById(string InspectionItemId) | 
					
						
							| 
									
										
										
										
											2025-03-07 16:30:12 +08:00
										 |  |  |  |         { | 
					
						
							|  |  |  |  |             var responeData = new Model.ResponeData(); | 
					
						
							|  |  |  |  |             try | 
					
						
							|  |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2025-04-06 23:26:22 +08:00
										 |  |  |  |                 responeData.data = Inspect_InspectionService.GetInspectItemsById(InspectionItemId); | 
					
						
							| 
									
										
										
										
											2025-03-07 16:30:12 +08:00
										 |  |  |  |             } | 
					
						
							|  |  |  |  |             catch (Exception ex) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 responeData.code = 0; | 
					
						
							|  |  |  |  |                 responeData.message = ex.Message; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return responeData; | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2025-04-06 23:26:22 +08:00
										 |  |  |  |         #endregion | 
					
						
							| 
									
										
										
										
											2025-03-07 16:30:12 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-06 23:26:22 +08:00
										 |  |  |  |         #region 根据项目和检查日期获取专检  (公司级查询) | 
					
						
							| 
									
										
										
										
											2025-04-15 20:48:53 +08:00
										 |  |  |  |         public Model.ResponeData getInspectionByProjectIdAndCheckDate(string projectId, string checkDate, string type) | 
					
						
							| 
									
										
										
										
											2025-03-07 16:30:12 +08:00
										 |  |  |  |         { | 
					
						
							|  |  |  |  |             var responeData = new Model.ResponeData(); | 
					
						
							|  |  |  |  |             try | 
					
						
							|  |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2025-04-06 23:26:22 +08:00
										 |  |  |  |                 DateTime mdate = Funs.GetNewDateTimeOrNow(checkDate); | 
					
						
							| 
									
										
										
										
											2025-03-07 16:30:12 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-06 23:26:22 +08:00
										 |  |  |  |                 var getDataLists = (from x in Funs.DB.Inspect_Inspection | 
					
						
							| 
									
										
										
										
											2025-04-15 20:48:53 +08:00
										 |  |  |  |                                     where x.InspectType == type | 
					
						
							| 
									
										
										
										
											2025-04-06 23:26:22 +08:00
										 |  |  |  |                                     select new InspectionDto | 
					
						
							| 
									
										
										
										
											2025-03-07 16:30:12 +08:00
										 |  |  |  |                                     { | 
					
						
							|  |  |  |  |                                         InspectionId = x.InspectionId, | 
					
						
							| 
									
										
										
										
											2025-04-06 23:26:22 +08:00
										 |  |  |  |                                         InspectionCode = x.InspectionCode, | 
					
						
							| 
									
										
										
										
											2025-03-07 16:30:12 +08:00
										 |  |  |  |                                         ProjectId = x.ProjectId, | 
					
						
							| 
									
										
										
										
											2025-04-06 23:26:22 +08:00
										 |  |  |  |                                         ProjectName = Funs.DB.Base_Project.FirstOrDefault(p => p.ProjectId == x.ProjectId).ProjectName, | 
					
						
							|  |  |  |  |                                         PersonResponsible = x.PersonResponsible, | 
					
						
							|  |  |  |  |                                         PersonResponsibleName = Funs.DB.Sys_User.FirstOrDefault(u => u.UserId == x.PersonResponsible).UserName, | 
					
						
							|  |  |  |  |                                         Description = x.Description, | 
					
						
							| 
									
										
										
										
											2025-03-07 16:30:12 +08:00
										 |  |  |  |                                         States = x.States, | 
					
						
							| 
									
										
										
										
											2025-04-06 23:26:22 +08:00
										 |  |  |  |                                         CreateManName = Funs.DB.Sys_User.FirstOrDefault(u => u.UserId == x.CreateMan).UserName, | 
					
						
							|  |  |  |  |                                         CreateMan = x.CreateMan, | 
					
						
							|  |  |  |  |                                         CreateTime = x.CreateTime, | 
					
						
							|  |  |  |  |                                         InspectType = x.InspectType, | 
					
						
							|  |  |  |  |                                         ProblemTypeId = x.ProblemTypeId, | 
					
						
							|  |  |  |  |                                         ProblemTypeName = x.ProblemTypeName, | 
					
						
							|  |  |  |  |                                         Place = x.Place, | 
					
						
							|  |  |  |  |                                         ChildsCount = (from a in Funs.DB.Inspect_InspectionItem | 
					
						
							|  |  |  |  |                                                          where a.InspectionId == x.InspectionId | 
					
						
							|  |  |  |  |                                                          select a).Count().ToString(), | 
					
						
							|  |  |  |  |                                     }); | 
					
						
							| 
									
										
										
										
											2025-04-15 20:48:53 +08:00
										 |  |  |  |                 if (!string.IsNullOrEmpty(projectId)&&projectId!=null) | 
					
						
							| 
									
										
										
										
											2025-04-06 23:26:22 +08:00
										 |  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2025-04-15 20:48:53 +08:00
										 |  |  |  |                     getDataLists = getDataLists.Where(q => q.ProjectId == projectId); | 
					
						
							| 
									
										
										
										
											2025-04-06 23:26:22 +08:00
										 |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2025-03-07 16:30:12 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-06 23:26:22 +08:00
										 |  |  |  |                  getDataLists  =  getDataLists.Where(q => q.CreateTime.Value.Year == mdate.Year | 
					
						
							|  |  |  |  |                                        && q.CreateTime.Value.Month == mdate.Month | 
					
						
							|  |  |  |  |                                        && q.CreateTime.Value.Day == mdate.Day); | 
					
						
							|  |  |  |  |                 responeData.data = getDataLists.ToList(); | 
					
						
							| 
									
										
										
										
											2025-03-07 16:30:12 +08:00
										 |  |  |  |             } | 
					
						
							|  |  |  |  |             catch (Exception ex) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 responeData.code = 0; | 
					
						
							|  |  |  |  |                 responeData.message = ex.Message; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return responeData; | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2025-04-06 23:26:22 +08:00
										 |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-07 16:30:12 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } |