diff --git a/SGGL/FineUIPro.Web/HJGL/NDT/NDTBatchImport.aspx.cs b/SGGL/FineUIPro.Web/HJGL/NDT/NDTBatchImport.aspx.cs index b080ccd1..bb89fc04 100644 --- a/SGGL/FineUIPro.Web/HJGL/NDT/NDTBatchImport.aspx.cs +++ b/SGGL/FineUIPro.Web/HJGL/NDT/NDTBatchImport.aspx.cs @@ -1,6 +1,7 @@ using BLL; using MiniExcelLibs; using Model; +using NPOI.SS.Util; using System; using System.Collections.Generic; using System.Data; @@ -141,19 +142,6 @@ namespace FineUIPro.Web.HJGL.NDT { if (e.EventArgument == "Confirm_OK") { - //string rootPath = Server.MapPath("~/"); - //string uploadfilepath = rootPath + Const.NDTBatchTemplateUrl; - //string filePath = Const.NDTBatchTemplateUrl; - //string fileName = Path.GetFileName(filePath); - //FileInfo info = new FileInfo(uploadfilepath); - //long fileSize = info.Length; - //Response.ClearContent(); - //Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8)); - //Response.ContentType = "excel/plain"; - //Response.ContentEncoding = System.Text.Encoding.UTF8; - //Response.AddHeader("Content-Length", fileSize.ToString().Trim()); - //Response.TransmitFile(uploadfilepath, 0, fileSize); - //Response.End(); string rootPath = Server.MapPath("~/"); string initTemplatePath = Const.NDTBatchTemplateUrl; string uploadfilepath = string.Empty; @@ -177,8 +165,8 @@ namespace FineUIPro.Web.HJGL.NDT NPOI.SS.UserModel.IWorkbook workbook; using (FileStream stream = new FileStream(newUrl, FileMode.Open, FileAccess.Read)) { - workbook = new NPOI.XSSF.UserModel.XSSFWorkbook(stream); - //workbook = new NPOI.HSSF.UserModel.HSSFWorkbook(stream); + workbook = new NPOI.XSSF.UserModel.XSSFWorkbook(stream);//.xlsx + //workbook = new NPOI.HSSF.UserModel.HSSFWorkbook(stream);//.xls } // 创建单元格样式 NPOI.SS.UserModel.ICellStyle cellStyle = workbook.CreateCellStyle(); @@ -188,17 +176,34 @@ namespace FineUIPro.Web.HJGL.NDT cellStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin; cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center; cellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center; - cellStyle.WrapText = true;//自动换行 + cellStyle.WrapText = true;//自动换行 var font = workbook.CreateFont(); font.FontHeightInPoints = 10; cellStyle.SetFont(font); - // 第二步:创建新数据行 + //尾部样式 + NPOI.SS.UserModel.ICellStyle bottomStyle = workbook.CreateCellStyle(); + bottomStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin; + bottomStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin; + bottomStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin; + bottomStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin; + bottomStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Left; + bottomStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Top; + bottomStyle.WrapText = true;//自动换行 + var bottomfont = workbook.CreateFont(); + bottomfont.FontHeightInPoints = 10; + bottomStyle.SetFont(bottomfont); + + //第二步:创建新数据行 NPOI.SS.UserModel.ISheet sheet = workbook.GetSheetAt(0); NPOI.SS.UserModel.IRow row = sheet.GetRow(0); NPOI.SS.UserModel.ICell cell; - // 添加数据 + //设置生成下拉框的行和列 + SetCellDropdownList(sheet, 6, 6, new List() { "合格", "不合格" }.ToArray());//是否合格 + SetCellDropdownList(sheet, 7, 7, new List() { "Ⅰ", "Ⅱ", "Ⅲ", "Ⅳ", "Ⅴ" }.ToArray());//评定级别 + + //添加数据 cell = row.CreateCell(7); cell.CellStyle = cellStyle; cell.SetCellValue(batchTrust.ProjectName);//工程名称 @@ -244,63 +249,351 @@ namespace FineUIPro.Web.HJGL.NDT if (!string.IsNullOrEmpty(batchTrustItemLists.FirstOrDefault().GrooveTypeCode)) { cell.SetCellValue(batchTrustItemLists.FirstOrDefault().GrooveTypeCode);//坡口形式 - } + } cell = row5.CreateCell(7); cell.CellStyle = cellStyle; cell.SetCellValue(batchTrust.DetectionRateValue + "%");//检测比例 - int i = 9; - foreach (var item in batchTrustItemLists) + //未满11行,填充空白行到11行;超过11行按实际行填充 + if (batchTrustItemLists.Count() < 11) { - // 第二步:创建新数据行 - row = sheet.CreateRow(i); - // 添加数据 + foreach (var item in batchTrustItemLists) + { + // 第二步:创建新数据行 + row = sheet.CreateRow(i); + // 添加数据 + cell = row.CreateCell(0); + cell.CellStyle = cellStyle; + cell.SetCellValue((i - 8).ToString());//序号 + + cell = row.CreateCell(1); + cell.CellStyle = cellStyle; + cell.SetCellValue(item.PipelineCode.ToString());//管线号 + + cell = row.CreateCell(2); + cell.CellStyle = cellStyle; + cell.SetCellValue(item.WeldJointCode);//焊口号 + + cell = row.CreateCell(3); + cell.CellStyle = cellStyle; + cell.SetCellValue(item.WelderCode);//焊工号 + + cell = row.CreateCell(4); + cell.CellStyle = cellStyle; + cell.SetCellValue("");//检测总数 + + cell = row.CreateCell(5); + cell.CellStyle = cellStyle; + cell.SetCellValue("");//合格数 + + cell = row.CreateCell(6); + cell.CellStyle = cellStyle; + cell.SetCellValue("");//是否合格 + + cell = row.CreateCell(7); + cell.CellStyle = cellStyle; + cell.SetCellValue("");//评定级别 + + cell = row.CreateCell(8); + cell.CellStyle = cellStyle; + cell.SetCellValue("");//缺陷 + + cell = row.CreateCell(9); + cell.CellStyle = cellStyle; + cell.SetCellValue("");//返修位置 + + cell = row.CreateCell(10); + cell.CellStyle = cellStyle; + cell.SetCellValue("");//备注 + i++; + } + + for (int j = 0; j < 11 - batchTrustItemLists.Count(); j++) + { + // 第二步:创建新数据行 + row = sheet.CreateRow(i); + // 添加数据 + cell = row.CreateCell(0); + cell.CellStyle = cellStyle; + cell.SetCellValue((i - 8).ToString());//序号 + + cell = row.CreateCell(1); + cell.CellStyle = cellStyle; + cell.SetCellValue("");//管线号 + + cell = row.CreateCell(2); + cell.CellStyle = cellStyle; + cell.SetCellValue("");//焊口号 + + cell = row.CreateCell(3); + cell.CellStyle = cellStyle; + cell.SetCellValue("");//焊工号 + + cell = row.CreateCell(4); + cell.CellStyle = cellStyle; + cell.SetCellValue("");//检测总数 + + cell = row.CreateCell(5); + cell.CellStyle = cellStyle; + cell.SetCellValue("");//合格数 + + cell = row.CreateCell(6); + cell.CellStyle = cellStyle; + cell.SetCellValue("");//是否合格 + + cell = row.CreateCell(7); + cell.CellStyle = cellStyle; + cell.SetCellValue("");//评定级别 + + cell = row.CreateCell(8); + cell.CellStyle = cellStyle; + cell.SetCellValue("");//缺陷 + + cell = row.CreateCell(9); + cell.CellStyle = cellStyle; + cell.SetCellValue("");//返修位置 + + cell = row.CreateCell(10); + cell.CellStyle = cellStyle; + cell.SetCellValue("");//备注 + + i++; + } + + //尾部 签字盖章 + // 创建新数据行 + row = sheet.CreateRow(20); + row.HeightInPoints = 43; + CellRangeAddress region = new CellRangeAddress(20, 20, 0, 1); + sheet.AddMergedRegion(region); cell = row.CreateCell(0); - cell.CellStyle = cellStyle; - cell.SetCellValue((i - 8).ToString());//序号 + cell.SetCellValue("委托方单位:"); + cell.CellStyle = bottomStyle; cell = row.CreateCell(1); - cell.CellStyle = cellStyle; - cell.SetCellValue(item.PipelineCode.ToString());//管线号 + cell.CellStyle = bottomStyle; + region = new CellRangeAddress(20, 20, 2, 3); + sheet.AddMergedRegion(region); cell = row.CreateCell(2); - cell.CellStyle = cellStyle; - cell.SetCellValue(item.WeldJointCode);//焊口号 + cell.SetCellValue("评片人:"); + cell.CellStyle = bottomStyle; cell = row.CreateCell(3); - cell.CellStyle = cellStyle; - cell.SetCellValue(item.WelderCode);//焊工号 + cell.CellStyle = bottomStyle; + region = new CellRangeAddress(20, 20, 4, 6); + sheet.AddMergedRegion(region); cell = row.CreateCell(4); - cell.CellStyle = cellStyle; - cell.SetCellValue("");//检测总数 + cell.SetCellValue("检测方单位:"); + cell.CellStyle = bottomStyle; cell = row.CreateCell(5); - cell.CellStyle = cellStyle; - cell.SetCellValue("");//合格数 - + cell.CellStyle = bottomStyle; cell = row.CreateCell(6); - cell.CellStyle = cellStyle; - cell.SetCellValue("");//是否合格 + cell.CellStyle = bottomStyle; + region = new CellRangeAddress(20, 20, 7, 10); + sheet.AddMergedRegion(region); cell = row.CreateCell(7); - cell.CellStyle = cellStyle; - cell.SetCellValue("");//评定级别 + cell.SetCellValue("监理单位:"); + cell.CellStyle = bottomStyle; cell = row.CreateCell(8); - cell.CellStyle = cellStyle; - cell.SetCellValue("");//缺陷 - + cell.CellStyle = bottomStyle; cell = row.CreateCell(9); - cell.CellStyle = cellStyle; - cell.SetCellValue("");//返修位置 - + cell.CellStyle = bottomStyle; cell = row.CreateCell(10); - cell.CellStyle = cellStyle; - cell.SetCellValue("");//备注 - i++; + cell.CellStyle = bottomStyle; + + row = sheet.CreateRow(21); + row.HeightInPoints = 43; + region = new CellRangeAddress(21, 21, 0, 1); + sheet.AddMergedRegion(region); + cell = row.CreateCell(0); + cell.SetCellValue("日期:"); + cell.CellStyle = bottomStyle; + + cell = row.CreateCell(1); + cell.CellStyle = bottomStyle; + + region = new CellRangeAddress(21, 21, 2, 3); + sheet.AddMergedRegion(region); + cell = row.CreateCell(2); + cell.SetCellValue("日期:"); + cell.CellStyle = bottomStyle; + + cell = row.CreateCell(3); + cell.CellStyle = bottomStyle; + + region = new CellRangeAddress(21, 21, 4, 6); + sheet.AddMergedRegion(region); + cell = row.CreateCell(4); + cell.SetCellValue("日期:"); + cell.CellStyle = bottomStyle; + + cell = row.CreateCell(5); + cell.CellStyle = bottomStyle; + cell = row.CreateCell(6); + cell.CellStyle = bottomStyle; + + region = new CellRangeAddress(21, 21, 7, 10); + sheet.AddMergedRegion(region); + cell = row.CreateCell(7); + cell.SetCellValue("日期:"); + cell.CellStyle = bottomStyle; + + cell = row.CreateCell(8); + cell.CellStyle = bottomStyle; + cell = row.CreateCell(9); + cell.CellStyle = bottomStyle; + cell = row.CreateCell(10); + cell.CellStyle = bottomStyle; + } + else + { + foreach (var item in batchTrustItemLists) + { + // 第二步:创建新数据行 + row = sheet.CreateRow(i); + // 添加数据 + cell = row.CreateCell(0); + cell.CellStyle = cellStyle; + cell.SetCellValue((i - 8).ToString());//序号 + + cell = row.CreateCell(1); + cell.CellStyle = cellStyle; + cell.SetCellValue(item.PipelineCode.ToString());//管线号 + + cell = row.CreateCell(2); + cell.CellStyle = cellStyle; + cell.SetCellValue(item.WeldJointCode);//焊口号 + + cell = row.CreateCell(3); + cell.CellStyle = cellStyle; + cell.SetCellValue(item.WelderCode);//焊工号 + + cell = row.CreateCell(4); + cell.CellStyle = cellStyle; + cell.SetCellValue("");//检测总数 + + cell = row.CreateCell(5); + cell.CellStyle = cellStyle; + cell.SetCellValue("");//合格数 + + cell = row.CreateCell(6); + cell.CellStyle = cellStyle; + cell.SetCellValue("");//是否合格 + + cell = row.CreateCell(7); + cell.CellStyle = cellStyle; + cell.SetCellValue("");//评定级别 + + cell = row.CreateCell(8); + cell.CellStyle = cellStyle; + cell.SetCellValue("");//缺陷 + + cell = row.CreateCell(9); + cell.CellStyle = cellStyle; + cell.SetCellValue("");//返修位置 + + cell = row.CreateCell(10); + cell.CellStyle = cellStyle; + cell.SetCellValue("");//备注 + i++; + } + + //尾部 签字盖章 + // 创建新数据行 + row = sheet.CreateRow(i); + row.HeightInPoints = 43; + CellRangeAddress region = new CellRangeAddress(i, i, 0, 1); + sheet.AddMergedRegion(region); + cell = row.CreateCell(0); + cell.SetCellValue("委托方单位:"); + cell.CellStyle = bottomStyle; + + cell = row.CreateCell(1); + cell.CellStyle = bottomStyle; + + region = new CellRangeAddress(i, i, 2, 3); + sheet.AddMergedRegion(region); + cell = row.CreateCell(2); + cell.SetCellValue("评片人:"); + cell.CellStyle = bottomStyle; + + cell = row.CreateCell(3); + cell.CellStyle = bottomStyle; + + region = new CellRangeAddress(i, i, 4, 6); + sheet.AddMergedRegion(region); + cell = row.CreateCell(4); + cell.SetCellValue("检测方单位:"); + cell.CellStyle = bottomStyle; + + cell = row.CreateCell(5); + cell.CellStyle = bottomStyle; + cell = row.CreateCell(6); + cell.CellStyle = bottomStyle; + + region = new CellRangeAddress(i, i, 7, 10); + sheet.AddMergedRegion(region); + cell = row.CreateCell(7); + cell.SetCellValue("监理单位:"); + cell.CellStyle = bottomStyle; + + cell = row.CreateCell(8); + cell.CellStyle = bottomStyle; + cell = row.CreateCell(9); + cell.CellStyle = bottomStyle; + cell = row.CreateCell(10); + cell.CellStyle = bottomStyle; + + row = sheet.CreateRow(i + 1); + row.HeightInPoints = 43; + region = new CellRangeAddress(i + 1, i + 1, 0, 1); + sheet.AddMergedRegion(region); + cell = row.CreateCell(0); + cell.SetCellValue("日期:"); + cell.CellStyle = bottomStyle; + + cell = row.CreateCell(1); + cell.CellStyle = bottomStyle; + + region = new CellRangeAddress(i + 1, i + 1, 2, 3); + sheet.AddMergedRegion(region); + cell = row.CreateCell(2); + cell.SetCellValue("日期:"); + cell.CellStyle = bottomStyle; + + cell = row.CreateCell(3); + cell.CellStyle = bottomStyle; + + region = new CellRangeAddress(i + 1, i + 1, 4, 6); + sheet.AddMergedRegion(region); + cell = row.CreateCell(4); + cell.SetCellValue("日期:"); + cell.CellStyle = bottomStyle; + + cell = row.CreateCell(5); + cell.CellStyle = bottomStyle; + cell = row.CreateCell(6); + cell.CellStyle = bottomStyle; + + region = new CellRangeAddress(i + 1, i + 1, 7, 10); + sheet.AddMergedRegion(region); + cell = row.CreateCell(7); + cell.SetCellValue("日期:"); + cell.CellStyle = bottomStyle; + + cell = row.CreateCell(8); + cell.CellStyle = bottomStyle; + cell = row.CreateCell(9); + cell.CellStyle = bottomStyle; + cell = row.CreateCell(10); + cell.CellStyle = bottomStyle; } // 第三步:写入文件流 using (FileStream stream = new FileStream(newUrl, FileMode.Create, FileAccess.Write)) @@ -322,7 +615,37 @@ namespace FineUIPro.Web.HJGL.NDT } } } + + /// + /// 设置单元格下拉框约束 + /// + /// + /// + /// + /// + public static void SetCellDropdownList(NPOI.SS.UserModel.ISheet sheet, int firstcol, int lastcol, string[] vals) + { + //设置生成下拉框的行和列 + var cellRegions = new CellRangeAddressList(1, 65535, firstcol, lastcol); + NPOI.SS.UserModel.IDataValidation validation = null; + + if (sheet.GetType().Name.Contains("XSSF")) // .xlsx + { + NPOI.XSSF.UserModel.XSSFDataValidationHelper helper = new NPOI.XSSF.UserModel.XSSFDataValidationHelper((NPOI.XSSF.UserModel.XSSFSheet)sheet);//获得一个数据验证Helper + //IDataValidation + validation = helper.CreateValidation( + helper.CreateExplicitListConstraint(vals), cellRegions);//创建约束 + } + else // HSSF .xls + { + //設置 下拉框內容 + NPOI.HSSF.UserModel.DVConstraint constraint = NPOI.HSSF.UserModel.DVConstraint.CreateExplicitListConstraint(vals); + validation = new NPOI.HSSF.UserModel.HSSFDataValidation(cellRegions, constraint); + } + sheet.AddValidationData(validation); + } #endregion + #region 将Dataset的数据导入数据库 /// /// 将Dataset的数据导入数据库 @@ -341,7 +664,7 @@ namespace FineUIPro.Web.HJGL.NDT responeData.message = "导入Excel格式错误!Excel只有" + count.ToString().Trim() + "列"; return responeData; } - if (pds.Count > 0 && pds != null) + if (pds.Count-2 > 0 && pds != null) { string NDEId = string.Empty; //string unitworkId = string.Empty; @@ -415,143 +738,138 @@ namespace FineUIPro.Web.HJGL.NDT ndes.Add(nde); } - for (int i = 9; i < pds.Count; i++) + for (int i = 9; i < pds.Count - 2; i++) { - HJGL_Batch_NDEItem item = new HJGL_Batch_NDEItem(); - item.NDEItemID = SQLHelper.GetNewID(typeof(Model.HJGL_Batch_NDEItem)); - item.NDEID = NDEId; - var batchTrustItems = BLL.Batch_BatchTrustItemService.GetViewBatchTrustItem(this.TrustBatchId); - if (batchTrustItems != null) + if (!string.IsNullOrEmpty(pds[i].B.ToString()) && !string.IsNullOrEmpty(pds[i].C.ToString())) { - var trustItem = batchTrustItems.FirstOrDefault(x => x.PipelineCode == pds[i].B.ToString() && x.WeldJointCode == pds[i].C.ToString()); - if (trustItem != null) + HJGL_Batch_NDEItem item = new HJGL_Batch_NDEItem(); + item.NDEItemID = SQLHelper.GetNewID(typeof(Model.HJGL_Batch_NDEItem)); + item.NDEID = NDEId; + var batchTrustItems = BLL.Batch_BatchTrustItemService.GetViewBatchTrustItem(this.TrustBatchId); + if (batchTrustItems != null) { - item.TrustBatchItemId = trustItem.TrustBatchItemId; - item.DetectionTypeId = trustItem.DetectionTypeId; - - //检测总数 - if (pds[i].E != null && !string.IsNullOrEmpty(pds[i].E.ToString())) + var trustItem = batchTrustItems.FirstOrDefault(x => x.PipelineCode == pds[i].B.ToString() && x.WeldJointCode == pds[i].C.ToString()); + if (trustItem != null) { - try + item.TrustBatchItemId = trustItem.TrustBatchItemId; + item.DetectionTypeId = trustItem.DetectionTypeId; + + //检测总数 + if (pds[i].E != null && !string.IsNullOrEmpty(pds[i].E.ToString())) { - item.TotalFilm = Funs.GetNewInt(pds[i].E.ToString()); - if (item.TotalFilm == null) + try + { + item.TotalFilm = Funs.GetNewInt(pds[i].E.ToString()); + if (item.TotalFilm == null) + { + result.Add("检测总数[" + pds[i].E.ToString() + "]格式错误"); + } + } + catch (Exception) { result.Add("检测总数[" + pds[i].E.ToString() + "]格式错误"); } } - catch (Exception) + //合格数 + if (pds[i].F != null && !string.IsNullOrEmpty(pds[i].F.ToString())) { - result.Add("检测总数[" + pds[i].E.ToString() + "]格式错误"); - } - } - //合格数 - if (pds[i].F != null && !string.IsNullOrEmpty(pds[i].F.ToString())) - { - try - { - item.PassFilm = Funs.GetNewInt(pds[i].F.ToString()); - if (item.PassFilm == null) + try + { + item.PassFilm = Funs.GetNewInt(pds[i].F.ToString()); + if (item.PassFilm == null) + { + result.Add("合格数[" + pds[i].F.ToString() + "]格式错误"); + } + } + catch (Exception) { result.Add("合格数[" + pds[i].F.ToString() + "]格式错误"); } } - catch (Exception) + //是否合格 + if (pds[i].G != null && !string.IsNullOrEmpty(pds[i].G.ToString())) { - result.Add("合格数[" + pds[i].F.ToString() + "]格式错误"); - } - } - //是否合格 - if (pds[i].G != null && !string.IsNullOrEmpty(pds[i].G.ToString())) - { - if (pds[i].G.ToString() == "合格" || pds[i].G.ToString() == "不合格") - { - item.CheckResult = pds[i].G.ToString() == "合格" ? "1" : "2"; - } - else - { - result.Add("是否合格[" + pds[i].G.ToString() + "]格式错误"); - } - } - //评定级别 - if (pds[i].H != null && !string.IsNullOrEmpty(pds[i].H.ToString())) - { - string gudgeGrade = pds[i].H.ToString(); - if (gudgeGrade != "Ⅰ" && gudgeGrade != "Ⅱ" && gudgeGrade != "Ⅲ" && gudgeGrade != "Ⅳ" && gudgeGrade != "Ⅴ") - { - result.Add("评定级别" + gudgeGrade + "错误"); - } - else - { - item.JudgeGrade = gudgeGrade; - } - } - //缺陷 - if (pds[i].I != null && !string.IsNullOrEmpty(pds[i].I.ToString())) - { - string checkDefects = pds[i].I.ToString(); - string defectIds = string.Empty; - string[] lists = checkDefects.Split(','); - foreach (var j in lists) - { - var u = defects.Where(x => x.DefectName == j.Trim()).FirstOrDefault(); - if (u == null) + if (pds[i].G.ToString() == "合格" || pds[i].G.ToString() == "不合格") { - result.Add("缺陷" + j.Trim() + "不存在"); + item.CheckResult = pds[i].G.ToString() == "合格" ? "1" : "2"; } else { - var q = BLL.Base_DefectService.GetDefectByDefectName(u.DefectName); - defectIds += q.DefectId + ","; + result.Add("是否合格[" + pds[i].G.ToString() + "]格式错误"); } } - if (!string.IsNullOrEmpty(defectIds)) + //评定级别 + if (pds[i].H != null && !string.IsNullOrEmpty(pds[i].H.ToString())) { - defectIds = defectIds.Substring(0, defectIds.LastIndexOf(",")); - item.CheckDefects = defectIds; + string gudgeGrade = pds[i].H.ToString(); + if (gudgeGrade != "Ⅰ" && gudgeGrade != "Ⅱ" && gudgeGrade != "Ⅲ" && gudgeGrade != "Ⅳ" && gudgeGrade != "Ⅴ") + { + result.Add("评定级别" + gudgeGrade + "错误"); + } + else + { + item.JudgeGrade = gudgeGrade; + } } - } - //返修位置 - if (pds[i].J != null && !string.IsNullOrEmpty(pds[i].J.ToString())) - { - item.RepairLocation = pds[i].J.ToString(); - } - if (pds[i].K != null && !string.IsNullOrEmpty(pds[i].K.ToString())) - { - item.Remark = pds[i].K.ToString(); - } - //报告日期 - if (pds[6].H != null && !string.IsNullOrEmpty(pds[6].H.ToString())) - { - try + //缺陷 + if (pds[i].I != null && !string.IsNullOrEmpty(pds[i].I.ToString())) { - item.ReportDate = Funs.GetNewDateTime(pds[6].H.ToString()); - if (item.ReportDate == null) + string checkDefects = pds[i].I.ToString(); + string defectIds = string.Empty; + string[] lists = checkDefects.Split(','); + foreach (var j in lists) + { + var u = defects.Where(x => x.DefectName == j.Trim()).FirstOrDefault(); + if (u == null) + { + result.Add("缺陷" + j.Trim() + "不存在"); + } + else + { + var q = BLL.Base_DefectService.GetDefectByDefectName(u.DefectName); + defectIds += q.DefectId + ","; + } + } + if (!string.IsNullOrEmpty(defectIds)) + { + defectIds = defectIds.Substring(0, defectIds.LastIndexOf(",")); + item.CheckDefects = defectIds; + } + } + //返修位置 + if (pds[i].J != null && !string.IsNullOrEmpty(pds[i].J.ToString())) + { + item.RepairLocation = pds[i].J.ToString(); + } + if (pds[i].K != null && !string.IsNullOrEmpty(pds[i].K.ToString())) + { + item.Remark = pds[i].K.ToString(); + } + //报告日期 + if (pds[6].H != null && !string.IsNullOrEmpty(pds[6].H.ToString())) + { + try + { + item.ReportDate = Funs.GetNewDateTime(pds[6].H.ToString()); + if (item.ReportDate == null) + { + result.Add("报告日期" + pds[6].H.ToString() + "格式错误"); + } + } + catch (Exception) { result.Add("报告日期" + pds[6].H.ToString() + "格式错误"); } } - catch (Exception) - { - result.Add("报告日期" + pds[6].H.ToString() + "格式错误"); - } } + else + { + result.Add("管线[" + pds[i].B.ToString() + "]焊口[" + pds[i].C.ToString() + "]" + "不存在该委托单中"); + } + item.SubmitDate = DateTime.Now; + ndeItems.Add(item); } - else - { - result.Add("管线[" + pds[i].B.ToString() + "]焊口[" + pds[i].C.ToString() + "]" + "不存在该委托单中"); - } - //var model = ndeItems.Where(x => x.TrustBatchItemId == item.TrustBatchItemId); - //if (model.Count() == 0) - //{ - item.SubmitDate = DateTime.Now; - ndeItems.Add(item); - //} - // } } - #region 数据验证和赋值 - - #endregion } } else diff --git a/SGGL/FineUIPro.Web/HJGL/PointTrust/TrustBatch.aspx.cs b/SGGL/FineUIPro.Web/HJGL/PointTrust/TrustBatch.aspx.cs index ecde9749..229f1e7b 100644 --- a/SGGL/FineUIPro.Web/HJGL/PointTrust/TrustBatch.aspx.cs +++ b/SGGL/FineUIPro.Web/HJGL/PointTrust/TrustBatch.aspx.cs @@ -1057,7 +1057,15 @@ namespace FineUIPro.Web.HJGL.PointTrust { if (pointBatchItem.IsBuildTrust != null) { - pointBatchItem.IsBuildTrust = null; + pointBatchItem.IsBuildTrust = null;//是否委托 + pointBatchItem.PointState = null;//点口类型 + pointBatchItem.PointDate = null;//点口时间 + db.SubmitChanges(); + } + var pointBatch = BLL.PointBatchService.GetPointBatchById(pointBatchItem.PointBatchId); + if (pointBatch!=null) + { + pointBatch.IsClosed = null; db.SubmitChanges(); } }