| 
									
										
										
										
											2024-09-20 08:49:45 +08:00
										 |  |  |  | using Model.CQMS; | 
					
						
							|  |  |  |  | using System; | 
					
						
							|  |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | using System.Linq; | 
					
						
							|  |  |  |  | using System.Text; | 
					
						
							|  |  |  |  | using System.Threading.Tasks; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace BLL.API.CQMS | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |    public class ApiInspectionManagementService | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         public static bool AddInspectionManagement(InspectionManagement inspectionManagement) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             using (var db = new Model.SGGLDB(Funs.ConnString)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 Model.ProcessControl_InspectionManagement newInspectionManagement = null; | 
					
						
							|  |  |  |  |                 if (!string.IsNullOrEmpty(inspectionManagement.InspectionId)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     newInspectionManagement = db.ProcessControl_InspectionManagement.FirstOrDefault(x => x.InspectionId == inspectionManagement.InspectionId); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 if (newInspectionManagement == null) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     newInspectionManagement = new Model.ProcessControl_InspectionManagement(); | 
					
						
							|  |  |  |  |                     newInspectionManagement.InspectionId = Guid.NewGuid().ToString(); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 newInspectionManagement.InspectionId = inspectionManagement.InspectionId; | 
					
						
							|  |  |  |  |                 newInspectionManagement.ProjectId = inspectionManagement.ProjectId; | 
					
						
							|  |  |  |  |                 newInspectionManagement.UnitId = inspectionManagement.UnitId; | 
					
						
							|  |  |  |  |                 newInspectionManagement.CNProfessionalId = inspectionManagement.CNProfessionalId; | 
					
						
							|  |  |  |  |                 newInspectionManagement.InspectionCode = inspectionManagement.InspectionCode; | 
					
						
							|  |  |  |  |                 newInspectionManagement.UnitWorkId = inspectionManagement.UnitWorkId; | 
					
						
							|  |  |  |  |                 newInspectionManagement.Branch = inspectionManagement.Branch; | 
					
						
							|  |  |  |  |                 newInspectionManagement.ControlPointType = inspectionManagement.ControlPointType; | 
					
						
							|  |  |  |  |                 newInspectionManagement.AcceptanceSite = inspectionManagement.AcceptanceSite; | 
					
						
							| 
									
										
										
										
											2025-10-24 18:27:46 +08:00
										 |  |  |  |                 newInspectionManagement.IsOnceQualified = (inspectionManagement.IsOnceQualified == "true"|| inspectionManagement.IsOnceQualified == "True") ? true : false; | 
					
						
							| 
									
										
										
										
											2024-09-20 08:49:45 +08:00
										 |  |  |  |                 if (!string.IsNullOrEmpty(inspectionManagement.InspectionDate)) | 
					
						
							|  |  |  |  |                     newInspectionManagement.InspectionDate = DateTime.Parse(inspectionManagement.InspectionDate); | 
					
						
							|  |  |  |  |                 newInspectionManagement.AttachUrl = inspectionManagement.AttachUrl; | 
					
						
							|  |  |  |  |                 newInspectionManagement.AttachUrl2 = inspectionManagement.AttachUrl2; | 
					
						
							|  |  |  |  |                 newInspectionManagement.NoticeCode = inspectionManagement.NoticeCode; | 
					
						
							|  |  |  |  |                 newInspectionManagement.ParentDivisionProjectId = inspectionManagement.ParentDivisionProjectId; | 
					
						
							|  |  |  |  |                 if (!string.IsNullOrEmpty(inspectionManagement.CheckDate)) | 
					
						
							|  |  |  |  |                     newInspectionManagement.CheckDate = DateTime.Parse(inspectionManagement.CheckDate); | 
					
						
							|  |  |  |  |                 newInspectionManagement.CheckMan = inspectionManagement.CheckMan; | 
					
						
							|  |  |  |  |                 newInspectionManagement.CompileMan = inspectionManagement.CompileMan; | 
					
						
							|  |  |  |  |                 //newInspectionManagement.CompileMan2 = inspectionManagement.CompileMan2; | 
					
						
							|  |  |  |  |                 if (!string.IsNullOrEmpty(inspectionManagement.CompileDate)) | 
					
						
							|  |  |  |  |                     newInspectionManagement.CompileDate = DateTime.Parse(inspectionManagement.CompileDate); | 
					
						
							|  |  |  |  |                 newInspectionManagement.UnqualifiedReason = inspectionManagement.UnqualifiedReason; | 
					
						
							|  |  |  |  |                 newInspectionManagement.AcceptanceCheckMan = inspectionManagement.AcceptanceCheckMan; | 
					
						
							|  |  |  |  |                 newInspectionManagement.FileType = inspectionManagement.FileType; | 
					
						
							|  |  |  |  |                 //newInspectionManagement.CCUnitIds = inspectionManagement.CCUnitIds; | 
					
						
							|  |  |  |  |                 //newInspectionManagement.MainSendUnitId = inspectionManagement.MainSendUnitId; | 
					
						
							|  |  |  |  |                 //newInspectionManagement.AuditMan = inspectionManagement.AuditMan; | 
					
						
							|  |  |  |  |                 //newInspectionManagement.Status = inspectionManagement.Status; | 
					
						
							|  |  |  |  |                 //if (!string.IsNullOrEmpty(inspectionManagement.PlanComplateDate)) | 
					
						
							|  |  |  |  |                 //    newInspectionManagement.PlanComplateDate = DateTime.Parse(inspectionManagement.PlanComplateDate); | 
					
						
							|  |  |  |  |                 db.ProcessControl_InspectionManagement.InsertOnSubmit(newInspectionManagement); | 
					
						
							|  |  |  |  |                 db.SubmitChanges(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 foreach (var InspectionDetail in inspectionManagement.inspectionManagementDetails) | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     Model.ProcessControl_InspectionManagementDetail newInspectionDetail = new Model.ProcessControl_InspectionManagementDetail(); | 
					
						
							|  |  |  |  |                     newInspectionDetail.InspectionDetailId = InspectionDetail.InspectionDetailId; | 
					
						
							|  |  |  |  |                     newInspectionDetail.InspectionId = newInspectionManagement.InspectionId; | 
					
						
							|  |  |  |  |                     newInspectionDetail.UnitWorkId = InspectionDetail.UnitWorkId; | 
					
						
							|  |  |  |  |                     newInspectionDetail.Branch = InspectionDetail.Branch; | 
					
						
							|  |  |  |  |                     newInspectionDetail.ControlPointType = InspectionDetail.ControlPointType; | 
					
						
							|  |  |  |  |                     if (!string.IsNullOrEmpty(InspectionDetail.CreateDate)) | 
					
						
							|  |  |  |  |                         newInspectionDetail.CreateDate = DateTime.Parse(InspectionDetail.CreateDate); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     db.ProcessControl_InspectionManagementDetail.InsertOnSubmit(newInspectionDetail); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 db.SubmitChanges(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return true; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 获取分部 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="Branch"></param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         protected static string ConvertBranch(object Branch) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             string name = string.Empty; | 
					
						
							|  |  |  |  |             if (Branch != null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 var branch = BLL.DivisionProjectService.GetDivisionProjectById(Branch.ToString()); | 
					
						
							|  |  |  |  |                 if (branch != null) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     name = branch.DivisionName; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return name; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 获取控制点内容 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="ControlPointType"></param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         protected static string ConvertControlPointType(object ControlPointType) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             string name = string.Empty; | 
					
						
							|  |  |  |  |             if (ControlPointType != null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 var controlPointType = BLL.BreakdownProjectService.GetBreakdownProjectById(ControlPointType.ToString()); | 
					
						
							|  |  |  |  |                 if (controlPointType != null) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     name = controlPointType.BreakdownName; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return name; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 获取控制点等级 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="ControlPointType"></param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         protected static string ConvertClass(object ControlPointType) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             string name = string.Empty; | 
					
						
							|  |  |  |  |             if (ControlPointType != null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 var controlPointType = BLL.BreakdownProjectService.GetBreakdownProjectById(ControlPointType.ToString()); | 
					
						
							|  |  |  |  |                 if (controlPointType != null) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     name = controlPointType.Class; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return name; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         public static List<InspectionManagementDetail> getInspectionManagementDetail(string projectId, int index, int page, string state, string name) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             using (var db = new Model.SGGLDB(Funs.ConnString)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 var dataList = from x in db.ProcessControl_InspectionManagementDetail | 
					
						
							|  |  |  |  |                                where x.ProcessControl_InspectionManagement.ProjectId == projectId | 
					
						
							|  |  |  |  |                                select x; | 
					
						
							|  |  |  |  |                 var listRes = dataList.Skip(index * page).Take(page); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 List<InspectionManagementDetail> list = new List<InspectionManagementDetail>(); | 
					
						
							|  |  |  |  |                 foreach (var item in listRes) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     InspectionManagementDetail detail = new InspectionManagementDetail() | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         InspectionDetailId = item.InspectionDetailId, | 
					
						
							|  |  |  |  |                         UnitWorkId = item.UnitWorkId, | 
					
						
							|  |  |  |  |                         UnitWorkName = db.WBS_UnitWork.FirstOrDefault(x => x.UnitWorkId == item.UnitWorkId).UnitWorkName, | 
					
						
							|  |  |  |  |                         ControlPointType = item.ControlPointType, | 
					
						
							|  |  |  |  |                         CreateDate = item.CreateDate.HasValue ? item.CreateDate.Value.ToString("yyyy-MM-dd") : "", | 
					
						
							|  |  |  |  |                         Branch = item.Branch, | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                         BranchName= ConvertBranch(item.Branch), | 
					
						
							|  |  |  |  |                         ControlPointTypeName= ConvertControlPointType(item.ControlPointType), | 
					
						
							|  |  |  |  |                         ControlPointTypeLevel= ConvertClass(item.ControlPointType) | 
					
						
							|  |  |  |  |                     }; | 
					
						
							|  |  |  |  |                     InspectionManagement inspectionManagement = new InspectionManagement(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     inspectionManagement.InspectionId = item.ProcessControl_InspectionManagement.InspectionId; | 
					
						
							|  |  |  |  |                     inspectionManagement.ProjectId = item.ProcessControl_InspectionManagement.ProjectId; | 
					
						
							|  |  |  |  |                     inspectionManagement.ProjectName = db.Base_Project.FirstOrDefault(x => x.ProjectId == item.ProcessControl_InspectionManagement.ProjectId).ProjectName; | 
					
						
							|  |  |  |  |                     inspectionManagement.UnitId = item.ProcessControl_InspectionManagement.UnitId; | 
					
						
							|  |  |  |  |                     inspectionManagement.UnitName = db.Base_Unit.FirstOrDefault(x => x.UnitId == item.ProcessControl_InspectionManagement.UnitId).UnitName; | 
					
						
							|  |  |  |  |                     inspectionManagement.CNProfessionalId = item.ProcessControl_InspectionManagement.CNProfessionalId; | 
					
						
							|  |  |  |  |                     if (!string.IsNullOrEmpty(inspectionManagement.CNProfessionalId)) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         inspectionManagement.CNProfessionalName = db.Base_CNProfessional.FirstOrDefault(x => x.CNProfessionalId == item.ProcessControl_InspectionManagement.CNProfessionalId).ProfessionalName; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     inspectionManagement.InspectionCode = item.ProcessControl_InspectionManagement.InspectionCode; | 
					
						
							|  |  |  |  |                     inspectionManagement.UnitWorkId = item.ProcessControl_InspectionManagement.UnitWorkId; | 
					
						
							|  |  |  |  |                     if (!string.IsNullOrEmpty(inspectionManagement.UnitWorkId)) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         inspectionManagement.UnitWorkName = db.WBS_UnitWork.FirstOrDefault(x => x.UnitWorkId == item.ProcessControl_InspectionManagement.UnitWorkId).UnitWorkName; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     inspectionManagement.Branch = item.ProcessControl_InspectionManagement.Branch; | 
					
						
							|  |  |  |  |                     inspectionManagement.ControlPointType = item.ProcessControl_InspectionManagement.ControlPointType; | 
					
						
							|  |  |  |  |                     inspectionManagement.AcceptanceSite = item.ProcessControl_InspectionManagement.AcceptanceSite; | 
					
						
							|  |  |  |  |                     inspectionManagement.IsOnceQualified = item.ProcessControl_InspectionManagement.IsOnceQualified.HasValue ? item.ProcessControl_InspectionManagement.IsOnceQualified.Value.ToString() : ""; | 
					
						
							|  |  |  |  |                     inspectionManagement.InspectionDate = item.ProcessControl_InspectionManagement.InspectionDate.HasValue ? "" : ""; | 
					
						
							|  |  |  |  |                     inspectionManagement.AttachUrl = item.ProcessControl_InspectionManagement.AttachUrl; | 
					
						
							|  |  |  |  |                     inspectionManagement.CheckDate = item.ProcessControl_InspectionManagement.CheckDate.HasValue ? item.ProcessControl_InspectionManagement.CheckDate.Value.ToString("yyyy-MM-dd") : ""; | 
					
						
							|  |  |  |  |                     inspectionManagement.CheckMan = item.ProcessControl_InspectionManagement.CheckMan; | 
					
						
							|  |  |  |  |                     inspectionManagement.CheckMan = item.ProcessControl_InspectionManagement.CheckMan; | 
					
						
							|  |  |  |  |                     inspectionManagement.UnqualifiedReason = item.ProcessControl_InspectionManagement.UnqualifiedReason; | 
					
						
							|  |  |  |  |                     inspectionManagement.NoticeCode = item.ProcessControl_InspectionManagement.NoticeCode; | 
					
						
							| 
									
										
										
										
											2025-06-04 15:26:39 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |                     var acceptanceCheckMan = BLL.UserService.getUserNamesUserIds(item.ProcessControl_InspectionManagement.AcceptanceCheckMan); | 
					
						
							|  |  |  |  |                     if (string.IsNullOrEmpty(acceptanceCheckMan)) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         acceptanceCheckMan = item.ProcessControl_InspectionManagement.AcceptanceCheckMan.ToString(); | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     inspectionManagement.AcceptanceCheckMan = acceptanceCheckMan; | 
					
						
							| 
									
										
										
										
											2024-09-20 08:49:45 +08:00
										 |  |  |  |                     inspectionManagement.ParentDivisionProjectId = item.ProcessControl_InspectionManagement.ParentDivisionProjectId; | 
					
						
							|  |  |  |  |                     inspectionManagement.CompileMan = item.ProcessControl_InspectionManagement.CompileMan; | 
					
						
							|  |  |  |  |                     if (!string.IsNullOrEmpty(inspectionManagement.CompileMan)) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         inspectionManagement.CompileManName = db.Sys_User.FirstOrDefault(x => x.UserId == item.ProcessControl_InspectionManagement.CompileMan).UserName;  //item.ProcessControl_InspectionManagement.CompileManName; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     inspectionManagement.CompileDate = item.ProcessControl_InspectionManagement.CompileDate.HasValue ? item.ProcessControl_InspectionManagement.CompileDate.Value.ToString("yyyy-MM-dd") : ""; | 
					
						
							|  |  |  |  |                     inspectionManagement.FileType = item.ProcessControl_InspectionManagement.FileType; | 
					
						
							|  |  |  |  |                     inspectionManagement.AttachUrl2 = item.ProcessControl_InspectionManagement.AttachUrl2; | 
					
						
							|  |  |  |  |                     //inspectionManagement.MainSendUnitId = item.ProcessControl_InspectionManagement.MainSendUnitId; | 
					
						
							|  |  |  |  |                     if (!string.IsNullOrEmpty(inspectionManagement.MainSendUnitId)) | 
					
						
							|  |  |  |  |                         inspectionManagement.MainSendUnitName = UnitService.getUnitNamesUnitIds(inspectionManagement.MainSendUnitId);//item.ProcessControl_InspectionManagement.MainSendUnitName; | 
					
						
							|  |  |  |  |                     //inspectionManagement.CCUnitIds = item.ProcessControl_InspectionManagement.CCUnitIds; | 
					
						
							|  |  |  |  |                     if (!string.IsNullOrEmpty(inspectionManagement.CCUnitIds)) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         inspectionManagement.CCUnitName = UnitService.getUnitNamesUnitIds(inspectionManagement.CCUnitIds);//  item.ProcessControl_InspectionManagement.CCUnitName; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     //inspectionManagement.PlanComplateDate = item.ProcessControl_InspectionManagement.PlanComplateDate.HasValue ? item.ProcessControl_InspectionManagement.PlanComplateDate.Value.ToString("yyyy-MM-dd") : ""; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     //inspectionManagement.Status = item.ProcessControl_InspectionManagement.Status; | 
					
						
							|  |  |  |  |                     //inspectionManagement.CompileMan2 = item.ProcessControl_InspectionManagement.CompileMan2; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     //inspectionManagement.AuditMan = item.ProcessControl_InspectionManagement.AuditMan; | 
					
						
							|  |  |  |  |                     //if (!string.IsNullOrEmpty(inspectionManagement.AuditMan)) | 
					
						
							|  |  |  |  |                     //{ inspectionManagement.AuditManName = db.Sys_User.FirstOrDefault(x => x.UserId == item.ProcessControl_InspectionManagement.AuditMan).UserName; } | 
					
						
							|  |  |  |  |                     detail.inspectionManagement = inspectionManagement; | 
					
						
							|  |  |  |  |                     list.Add(detail); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 return list; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         public static List<InspectionManagement> getInspectionManagement(string projectId, int index, int page, string state, string name) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             using (var db = new Model.SGGLDB(Funs.ConnString)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 var dataList = from x in db.ProcessControl_InspectionManagement | 
					
						
							|  |  |  |  |                                where x.ProjectId == projectId | 
					
						
							|  |  |  |  |                                select x; | 
					
						
							|  |  |  |  |                 var listRes = dataList.Skip(index * page).Take(page); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 List<InspectionManagement> list = new List<InspectionManagement>(); | 
					
						
							|  |  |  |  |                 foreach (var item in listRes) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     InspectionManagement inspectionManagement = new InspectionManagement(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     inspectionManagement.InspectionId = item.InspectionId; | 
					
						
							|  |  |  |  |                     inspectionManagement.ProjectId = item.ProjectId; | 
					
						
							|  |  |  |  |                     inspectionManagement.ProjectName = db.Base_Project.FirstOrDefault(x => x.ProjectId == item.ProjectId).ProjectName; | 
					
						
							|  |  |  |  |                     inspectionManagement.UnitId = item.UnitId; | 
					
						
							|  |  |  |  |                     inspectionManagement.UnitName = db.Base_Unit.FirstOrDefault(x => x.UnitId == item.UnitId).UnitName; | 
					
						
							|  |  |  |  |                     inspectionManagement.CNProfessionalId = item.CNProfessionalId; | 
					
						
							|  |  |  |  |                    | 
					
						
							|  |  |  |  |                     if (!string.IsNullOrEmpty(inspectionManagement.CNProfessionalId)) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         inspectionManagement.CNProfessionalName = db.Base_CNProfessional.FirstOrDefault(x => x.CNProfessionalId == item.CNProfessionalId).ProfessionalName; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     inspectionManagement.InspectionCode = item.InspectionCode; | 
					
						
							|  |  |  |  |                     inspectionManagement.UnitWorkId = item.UnitWorkId; | 
					
						
							|  |  |  |  |                     if (!string.IsNullOrEmpty(inspectionManagement.UnitWorkId)) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         inspectionManagement.UnitWorkName = db.WBS_UnitWork.FirstOrDefault(x => x.UnitWorkId == item.UnitWorkId).UnitWorkName; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     inspectionManagement.Branch = item.Branch; | 
					
						
							|  |  |  |  |                     inspectionManagement.ControlPointType = item.ControlPointType; | 
					
						
							|  |  |  |  |                     inspectionManagement.AcceptanceSite = item.AcceptanceSite; | 
					
						
							|  |  |  |  |                     inspectionManagement.IsOnceQualified = item.IsOnceQualified.HasValue ? item.IsOnceQualified.Value.ToString() : ""; | 
					
						
							|  |  |  |  |                     inspectionManagement.InspectionDate = item.InspectionDate.HasValue ? "" : ""; | 
					
						
							|  |  |  |  |                     inspectionManagement.AttachUrl = item.AttachUrl; | 
					
						
							|  |  |  |  |                     inspectionManagement.CheckDate = item.CheckDate.HasValue ? item.CheckDate.Value.ToString("yyyy-MM-dd") : ""; | 
					
						
							|  |  |  |  |                     inspectionManagement.CheckMan = item.CheckMan; | 
					
						
							|  |  |  |  |                     inspectionManagement.UnqualifiedReason = item.UnqualifiedReason; | 
					
						
							|  |  |  |  |                     inspectionManagement.NoticeCode = item.NoticeCode; | 
					
						
							| 
									
										
										
										
											2025-06-04 15:26:39 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |                     var acceptanceCheckMan = BLL.UserService.getUserNamesUserIds(item.AcceptanceCheckMan); | 
					
						
							|  |  |  |  |                     if (string.IsNullOrEmpty(acceptanceCheckMan)) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         acceptanceCheckMan = item.AcceptanceCheckMan.ToString(); | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     inspectionManagement.AcceptanceCheckMan = acceptanceCheckMan; | 
					
						
							| 
									
										
										
										
											2024-09-20 08:49:45 +08:00
										 |  |  |  |                     inspectionManagement.ParentDivisionProjectId = item.ParentDivisionProjectId; | 
					
						
							|  |  |  |  |                     inspectionManagement.CompileMan = item.CompileMan; | 
					
						
							|  |  |  |  |                     if (!string.IsNullOrEmpty(inspectionManagement.CompileMan)) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         inspectionManagement.CompileManName = db.Sys_User.FirstOrDefault(x => x.UserId == item.CompileMan).UserName;  //item.CompileManName; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     inspectionManagement.CompileDate = item.CompileDate.HasValue ? item.CompileDate.Value.ToString("yyyy-MM-dd") : ""; | 
					
						
							|  |  |  |  |                     inspectionManagement.FileType = item.FileType; | 
					
						
							|  |  |  |  |                     inspectionManagement.AttachUrl2 = item.AttachUrl2; | 
					
						
							|  |  |  |  |                     //inspectionManagement.MainSendUnitId = item.MainSendUnitId; | 
					
						
							|  |  |  |  |                     if (!string.IsNullOrEmpty(inspectionManagement.MainSendUnitId)) | 
					
						
							|  |  |  |  |                         inspectionManagement.MainSendUnitName = UnitService.getUnitNamesUnitIds(inspectionManagement.MainSendUnitId);//item.MainSendUnitName; | 
					
						
							|  |  |  |  |                     //inspectionManagement.CCUnitIds = item.CCUnitIds; | 
					
						
							|  |  |  |  |                     if (!string.IsNullOrEmpty(inspectionManagement.CCUnitIds)) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         inspectionManagement.CCUnitName = UnitService.getUnitNamesUnitIds(inspectionManagement.CCUnitIds);//  item.CCUnitName; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     //inspectionManagement.PlanComplateDate = item.PlanComplateDate.HasValue ? item.PlanComplateDate.Value.ToString("yyyy-MM-dd") : ""; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     //inspectionManagement.Status = item.Status; | 
					
						
							|  |  |  |  |                     //inspectionManagement.CompileMan2 = item.CompileMan2; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     //inspectionManagement.AuditMan = item.AuditMan; | 
					
						
							|  |  |  |  |                     //if (!string.IsNullOrEmpty(inspectionManagement.AuditMan)) | 
					
						
							|  |  |  |  |                     //{ inspectionManagement.AuditManName = db.Sys_User.FirstOrDefault(x => x.UserId == item.AuditMan).UserName; } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     list.Add(inspectionManagement); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 return list; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         public static List<InspectionManagementDetail> getInspectionManagementDetailByinspectionId(string inspectionId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             using (var db = new Model.SGGLDB(Funs.ConnString)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 var dataList = from x in db.ProcessControl_InspectionManagementDetail | 
					
						
							|  |  |  |  |                                where x.InspectionId == inspectionId | 
					
						
							|  |  |  |  |                                select x; | 
					
						
							|  |  |  |  |                 var listRes = dataList.ToList(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 List<InspectionManagementDetail> list = new List<InspectionManagementDetail>(); | 
					
						
							|  |  |  |  |                 foreach (var item in listRes) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     InspectionManagementDetail detail = new InspectionManagementDetail(){ }; | 
					
						
							|  |  |  |  |                     detail.InspectionDetailId = item.InspectionDetailId; | 
					
						
							|  |  |  |  |                     detail.UnitWorkId = item.UnitWorkId; | 
					
						
							|  |  |  |  |                     detail.UnitWorkName = db.WBS_UnitWork.FirstOrDefault(x => x.UnitWorkId == item.UnitWorkId).UnitWorkName; | 
					
						
							|  |  |  |  |                     detail.ControlPointType = item.ControlPointType; | 
					
						
							|  |  |  |  |                     detail.CreateDate = item.CreateDate.HasValue ? item.CreateDate.Value.ToString("yyyy-MM-dd") : ""; | 
					
						
							|  |  |  |  |                     detail.Branch = item.Branch; | 
					
						
							|  |  |  |  |                     detail.BranchName = ConvertBranch(item.Branch); | 
					
						
							|  |  |  |  |                     detail.ControlPointTypeName = ConvertControlPointType(item.ControlPointType); | 
					
						
							|  |  |  |  |                     detail.ControlPointTypeLevel = ConvertClass(item.ControlPointType); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     InspectionManagement inspectionManagement = new InspectionManagement(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     inspectionManagement.InspectionId = item.ProcessControl_InspectionManagement.InspectionId; | 
					
						
							|  |  |  |  |                     inspectionManagement.ProjectId = item.ProcessControl_InspectionManagement.ProjectId; | 
					
						
							|  |  |  |  |                     inspectionManagement.ProjectName = db.Base_Project.FirstOrDefault(x => x.ProjectId == item.ProcessControl_InspectionManagement.ProjectId).ProjectName; | 
					
						
							|  |  |  |  |                     inspectionManagement.UnitId = item.ProcessControl_InspectionManagement.UnitId; | 
					
						
							|  |  |  |  |                     inspectionManagement.UnitName = db.Base_Unit.FirstOrDefault(x => x.UnitId == item.ProcessControl_InspectionManagement.UnitId).UnitName; | 
					
						
							|  |  |  |  |                     inspectionManagement.CNProfessionalId = item.ProcessControl_InspectionManagement.CNProfessionalId; | 
					
						
							|  |  |  |  |                     if (!string.IsNullOrEmpty(inspectionManagement.CNProfessionalId)) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         inspectionManagement.CNProfessionalName = db.Base_CNProfessional.FirstOrDefault(x => x.CNProfessionalId == item.ProcessControl_InspectionManagement.CNProfessionalId).ProfessionalName; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     inspectionManagement.InspectionCode = item.ProcessControl_InspectionManagement.InspectionCode; | 
					
						
							|  |  |  |  |                     inspectionManagement.UnitWorkId = item.ProcessControl_InspectionManagement.UnitWorkId; | 
					
						
							|  |  |  |  |                     if (!string.IsNullOrEmpty(inspectionManagement.UnitWorkId)) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         inspectionManagement.UnitWorkName = db.WBS_UnitWork.FirstOrDefault(x => x.UnitWorkId == item.ProcessControl_InspectionManagement.UnitWorkId).UnitWorkName; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     inspectionManagement.Branch = item.ProcessControl_InspectionManagement.Branch; | 
					
						
							|  |  |  |  |                     inspectionManagement.ControlPointType = item.ProcessControl_InspectionManagement.ControlPointType; | 
					
						
							|  |  |  |  |                     inspectionManagement.AcceptanceSite = item.ProcessControl_InspectionManagement.AcceptanceSite; | 
					
						
							|  |  |  |  |                     inspectionManagement.IsOnceQualified = item.ProcessControl_InspectionManagement.IsOnceQualified.HasValue ? item.ProcessControl_InspectionManagement.IsOnceQualified.Value.ToString() : ""; | 
					
						
							|  |  |  |  |                     inspectionManagement.InspectionDate = item.ProcessControl_InspectionManagement.InspectionDate.HasValue ? "" : ""; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     //inspectionManagement.AttachUrl = item.ProcessControl_InspectionManagement.AttachUrl; | 
					
						
							|  |  |  |  |                     inspectionManagement.AttachUrl = APIUpLoadFileService.getFileUrl(item.InspectionId, null); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     inspectionManagement.CheckDate = item.ProcessControl_InspectionManagement.CheckDate.HasValue ? item.ProcessControl_InspectionManagement.CheckDate.Value.ToString("yyyy-MM-dd") : ""; | 
					
						
							|  |  |  |  |                     inspectionManagement.CheckMan = item.ProcessControl_InspectionManagement.CheckMan; | 
					
						
							|  |  |  |  |                     inspectionManagement.UnqualifiedReason = item.ProcessControl_InspectionManagement.UnqualifiedReason; | 
					
						
							|  |  |  |  |                     inspectionManagement.NoticeCode = item.ProcessControl_InspectionManagement.NoticeCode; | 
					
						
							| 
									
										
										
										
											2025-06-04 15:26:39 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |                     var acceptanceCheckMan = BLL.UserService.getUserNamesUserIds(item.ProcessControl_InspectionManagement.AcceptanceCheckMan); | 
					
						
							|  |  |  |  |                     if (string.IsNullOrEmpty(acceptanceCheckMan)) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         acceptanceCheckMan = item.ProcessControl_InspectionManagement.AcceptanceCheckMan.ToString(); | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     inspectionManagement.AcceptanceCheckMan = acceptanceCheckMan; | 
					
						
							| 
									
										
										
										
											2024-09-20 08:49:45 +08:00
										 |  |  |  |                     inspectionManagement.ParentDivisionProjectId = item.ProcessControl_InspectionManagement.ParentDivisionProjectId; | 
					
						
							|  |  |  |  |                     inspectionManagement.CompileMan = item.ProcessControl_InspectionManagement.CompileMan; | 
					
						
							|  |  |  |  |                     if (!string.IsNullOrEmpty(inspectionManagement.CompileMan)) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         inspectionManagement.CompileManName = db.Sys_User.FirstOrDefault(x => x.UserId == item.ProcessControl_InspectionManagement.CompileMan).UserName;  //item.ProcessControl_InspectionManagement.CompileManName; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     inspectionManagement.CompileDate = item.ProcessControl_InspectionManagement.CompileDate.HasValue ? item.ProcessControl_InspectionManagement.CompileDate.Value.ToString("yyyy-MM-dd") : ""; | 
					
						
							|  |  |  |  |                     inspectionManagement.FileType = item.ProcessControl_InspectionManagement.FileType; | 
					
						
							|  |  |  |  |                     inspectionManagement.AttachUrl2 = item.ProcessControl_InspectionManagement.AttachUrl2; | 
					
						
							|  |  |  |  |                     //inspectionManagement.MainSendUnitId = item.ProcessControl_InspectionManagement.MainSendUnitId; | 
					
						
							|  |  |  |  |                     if (!string.IsNullOrEmpty(inspectionManagement.MainSendUnitId)) | 
					
						
							|  |  |  |  |                         inspectionManagement.MainSendUnitName = UnitService.getUnitNamesUnitIds(inspectionManagement.MainSendUnitId);//item.ProcessControl_InspectionManagement.MainSendUnitName; | 
					
						
							|  |  |  |  |                     //inspectionManagement.CCUnitIds = item.ProcessControl_InspectionManagement.CCUnitIds; | 
					
						
							|  |  |  |  |                     if (!string.IsNullOrEmpty(inspectionManagement.CCUnitIds)) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         inspectionManagement.CCUnitName = UnitService.getUnitNamesUnitIds(inspectionManagement.CCUnitIds);//  item.ProcessControl_InspectionManagement.CCUnitName; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     //inspectionManagement.PlanComplateDate = item.ProcessControl_InspectionManagement.PlanComplateDate.HasValue ? item.ProcessControl_InspectionManagement.PlanComplateDate.Value.ToString("yyyy-MM-dd") : ""; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     //inspectionManagement.Status = item.ProcessControl_InspectionManagement.Status; | 
					
						
							|  |  |  |  |                     //inspectionManagement.CompileMan2 = item.ProcessControl_InspectionManagement.CompileMan2; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     //inspectionManagement.AuditMan = item.ProcessControl_InspectionManagement.AuditMan; | 
					
						
							|  |  |  |  |                     //if (!string.IsNullOrEmpty(inspectionManagement.AuditMan)) | 
					
						
							|  |  |  |  |                     //{ inspectionManagement.AuditManName = db.Sys_User.FirstOrDefault(x => x.UserId == item.ProcessControl_InspectionManagement.AuditMan).UserName; } | 
					
						
							|  |  |  |  |                     detail.inspectionManagement = inspectionManagement; | 
					
						
							|  |  |  |  |                     list.Add(detail); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 return list; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } |