using BLL; using NPOI.HSSF.UserModel; using NPOI.SS.UserModel; using NPOI.SS.Util; using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.IO; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace FineUIPro.Web.CQMS.ConstructionLog { public partial class ConstructionLog : PageBase { /// /// 工程联系单主键 /// public string ConstructionLogId { get { return (string)ViewState["ConstructionLogId"]; } set { ViewState["ConstructionLogId"] = value; } } #region 获取按钮权限 /// /// 获取按钮权限 /// /// /// private void GetButtonPower() { if (Request.Params["value"] == "0") { return; } var buttonList = CommonService.GetAllButtonList(CurrUser.LoginProjectId, CurrUser.UserId, Const.CQMSConstructionLogMenuId); if (buttonList.Count() > 0) { if (buttonList.Contains(Const.BtnAdd)) { btnNew.Hidden = false; } if (buttonList.Contains(Const.BtnModify)) { btnMenuModify.Hidden = false; } if (buttonList.Contains(Const.BtnDelete)) { btnMenuDel.Hidden = false; } } } #endregion protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ddlPageSize.SelectedValue = Grid1.PageSize.ToString(); UnitService.InitUnitByProjectIdUnitTypeDropDownList2(drpUnit, this.CurrUser.LoginProjectId, true); btnNew.OnClientClick = window_tt.GetShowReference("ConstructionLogEdit.aspx", "施工日志") + "return false;"; GetButtonPower(); BindGrid(); } } protected DataTable ChecklistData() { string strSql = @"SELECT chec.ConstructionLogId,chec.ProjectId,chec.LogDate,chec.CompileMan,chec.CompileDate,u.userName,ut.UnitName,chec.State" + @" FROM CQMS_ConstructionLog chec " + @" left join sys_User u on u.userId = chec.CompileMan" + @" left join Base_Unit ut on ut.UnitId = chec.UnitId" + @" where chec.ProjectId=@ProjectId"; List listStr = new List(); listStr.Add(new SqlParameter("@ProjectId", CurrUser.LoginProjectId)); if (drpUnit.SelectedValue != BLL.Const._Null) { strSql += " AND (select ConstructionLogItemId from CQMS_ConstructionLogItem i where i.ConstructionLogId=chec.ConstructionLogId and i.UnitId=@unitId) is not null"; listStr.Add(new SqlParameter("@unitId", drpUnit.SelectedValue)); } if (!string.IsNullOrEmpty(this.txtCompileDate.Text.Trim())) { strSql += " AND chec.LogDate = @LogDate"; listStr.Add(new SqlParameter("@LogDate", this.txtCompileDate.Text.Trim())); } strSql += " order by chec.LogDate desc "; SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); return tb; } private void BindGrid() { var list = ChecklistData(); Grid1.RecordCount = list.Rows.Count; list = GetFilteredTable(Grid1.FilteredData, list); var table = GetPagedDataTable(Grid1, list); Grid1.DataSource = table; Grid1.DataBind(); } protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) { Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); BindGrid(); } #region 查询 /// /// 查询 /// /// /// protected void TextBox_TextChanged(object sender, EventArgs e) { this.BindGrid(); } #endregion protected void btnMenuModify_Click(object sender, EventArgs e) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); return; } ConstructionLogId = Grid1.SelectedRowID.Split(',')[0]; var constructionLog = BLL.CQMSConstructionLogService.GetConstructionLogById(ConstructionLogId); if (constructionLog != null) { if (constructionLog.State.Equals(Const.ConstructionLog_Complete)) { Alert.ShowInTop("该记录已审批完成,无法编辑,请右键查看!", MessageBoxIcon.Warning); return; } Model.CQMS_ConstructionLogApprove approve = BLL.CQMSConstructionLogApproveService.GetConstructionLogApproveByConstructionLogId(ConstructionLogId); if (approve != null) { if (!string.IsNullOrEmpty(approve.ApproveMan)) { if (this.CurrUser.UserId == approve.ApproveMan || CurrUser.UserId == Const.sysglyId || CurrUser.UserId == Const.hfnbdId) { PageContext.RegisterStartupScript(window_tt.GetShowReference(String.Format("ConstructionLogEdit.aspx?ConstructionLogId={0}", ConstructionLogId, "编辑 - "))); return; } else if (constructionLog.State == BLL.Const.CheckControl_Complete) { PageContext.RegisterStartupScript(window_tt.GetShowReference(String.Format("ConstructionLogView.aspx?ConstructionLogId={0}", ConstructionLogId, "查看 - "))); return; } else { Alert.ShowInTop("您不是当前办理人,无法编辑,请右键查看!", MessageBoxIcon.Warning); return; } } if (this.btnMenuModify.Hidden || constructionLog.State == BLL.Const.State_2) ////双击事件 编辑权限有:编辑页面,无:查看页面 或者状态是完成时查看页面 { PageContext.RegisterStartupScript(window_tt.GetShowReference(String.Format("ConstructionLogView.aspx?ConstructionLogId={0}", ConstructionLogId, "查看 - "))); return; } else { PageContext.RegisterStartupScript(window_tt.GetShowReference(String.Format("ConstructionLogEdit.aspx?ConstructionLogId={0}", ConstructionLogId, "编辑 - "))); return; } } else { Alert.ShowInTop("您不是当前办理人,无法编辑,请右键查看!", MessageBoxIcon.Warning); return; } } else { Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); return; } } protected void btnMenuDel_Click(object sender, EventArgs e) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); return; } ConstructionLogId = Grid1.SelectedRowID.Split(',')[0]; var constructionLog = CQMSConstructionLogService.GetConstructionLogById(ConstructionLogId); BLL.CQMSConstructionLogApproveService.DeleteConstructionLogApprovesByConstructionLogId(ConstructionLogId); BLL.CQMSConstructionLogItemService.DeleteConstructionLogItemById(ConstructionLogId); BLL.CQMSConstructionLogImageProgressService.DeleteConstructionLogImageProgressById(ConstructionLogId); BLL.CQMSConstructionLogService.DeleteConstructionLogById(ConstructionLogId); BLL.LogService.AddSys_Log(this.CurrUser, string.Format("{0:yyyy-MM-dd}", constructionLog.CompileDate), ConstructionLogId, Const.CQMSConstructionLogMenuId, "删除施工日志"); BindGrid(); ShowNotify("删除数据成功!", MessageBoxIcon.Success); } protected void window_tt_Close(object sender, WindowCloseEventArgs e) { BindGrid(); } protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e) { btnMenuModify_Click(sender, e); } protected void btnMenuView_Click(object sender, EventArgs e) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); return; } string ConstructionLogId = Grid1.SelectedRowID; PageContext.RegisterStartupScript(window_tt.GetShowReference(String.Format("ConstructionLogView.aspx?ConstructionLogId={0}", ConstructionLogId, "查看 - "))); } protected void Window1_Close(object sender, WindowCloseEventArgs e) { BindGrid(); } protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { BindGrid(); } /// /// 把状态转换代号为文字形式 /// /// /// protected string ConvertState(object state) { if (state != null) { if (state.ToString() == BLL.Const.ConstructionLog_ReCompile) { return "重新编制"; } else if (state.ToString() == BLL.Const.ConstructionLog_Compile) { return "编制"; } else if (state.ToString() == BLL.Const.ConstructionLog_Audit) { return "待审核"; } else if (state.ToString() == BLL.Const.ConstructionLog_Complete) { return "审批完成"; } else { return ""; } } return ""; } // //获取办理人姓名 // // // protected string ConvertMan(object ConstructionLogId) { if (ConstructionLogId != null) { Model.CQMS_ConstructionLogApprove a = BLL.CQMSConstructionLogApproveService.GetConstructionLogApproveByConstructionLogId(ConstructionLogId.ToString()); if (a != null) { if (a.ApproveMan != null) { return BLL.UserService.GetUserByUserId(a.ApproveMan).UserName; } } else { return ""; } } return ""; } // //获取施工单位 // // // protected string ConvertUnitName(object ConstructionLogId) { string unitName = string.Empty; if (ConstructionLogId != null) { var unitIds = from x in Funs.DB.CQMS_ConstructionLogItem where x.ConstructionLogId == ConstructionLogId.ToString() select x.UnitId; if (unitIds.Count() > 0) { foreach (var unitId in unitIds) { unitName += BLL.UnitService.GetUnitNameByUnitId(unitId) + ","; } if (!string.IsNullOrEmpty(unitName)) { unitName = unitName.Substring(0, unitName.Length - 1); } } } return unitName; } protected void Grid1_RowCommand(object sender, GridCommandEventArgs e) { string constructionLogId = this.Grid1.SelectedRowID; if (e.CommandName == "Out") { string rootPath = Server.MapPath("~/"); string initTemplatePath = string.Empty; string uploadfilepath = string.Empty; string newUrl = string.Empty; string filePath = string.Empty; initTemplatePath = Const.ConstructionLogTemplateUrl; uploadfilepath = rootPath + initTemplatePath; var constructionLog = BLL.CQMSConstructionLogService.GetConstructionLogById(constructionLogId); if (constructionLog != null) { string compileMan = BLL.UserService.GetUserNameByUserId(constructionLog.CompileMan); newUrl = uploadfilepath.Replace(".xlsx", "(" + compileMan + "_" + string.Format("{0:yyyy-MM-dd}", constructionLog.LogDate) + ").xlsx"); File.Copy(uploadfilepath, newUrl); // 第一步:读取文件流 NPOI.SS.UserModel.IWorkbook workbook; using (FileStream stream = new FileStream(newUrl, FileMode.Open, FileAccess.Read)) { workbook = new NPOI.XSSF.UserModel.XSSFWorkbook(stream); } Model.SGGLDB db = Funs.DB; var projects = from x in db.Base_Project select x; var lists = from x in db.CQMS_ConstructionLogItem where x.ConstructionLogId == constructionLogId select x; // 创建单元格样式 NPOI.SS.UserModel.ICellStyle cellStyle = workbook.CreateCellStyle(); cellStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin; cellStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin; cellStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin; cellStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin; cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Left; cellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center; cellStyle.WrapText = true; var font = workbook.CreateFont(); font.FontHeightInPoints = 10; font.FontName = "宋体"; cellStyle.SetFont(font); NPOI.SS.UserModel.ICellStyle cellStyleR = workbook.CreateCellStyle(); cellStyleR.BorderTop = NPOI.SS.UserModel.BorderStyle.None; cellStyleR.BorderRight = NPOI.SS.UserModel.BorderStyle.None; cellStyleR.BorderBottom = NPOI.SS.UserModel.BorderStyle.None; cellStyleR.BorderLeft = NPOI.SS.UserModel.BorderStyle.None; cellStyleR.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Right; cellStyleR.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center; cellStyleR.WrapText = true; var fontR = workbook.CreateFont(); fontR.FontHeightInPoints = 10; cellStyleR.SetFont(fontR); // 第二步:创建新数据行 NPOI.SS.UserModel.ISheet sheet = workbook.GetSheetAt(0); // 第二步:创建新数据行 int i = 1; NPOI.SS.UserModel.IRow row = sheet.CreateRow(i); NPOI.SS.UserModel.ICell cell; cell = row.CreateCell(0); cell.CellStyle = cellStyleR; DateTime? date = constructionLog.LogDate; string dateStr = string.Empty; if (date != null) { dateStr = date.Value.Year + "年" + date.Value.Month + "月" + date.Value.Day + "日 星期" + Funs.GetWeekDay(date.Value.DayOfWeek.ToString()); } cell.SetCellValue(dateStr); cell = row.CreateCell(1); cell.CellStyle = cellStyleR; cell.SetCellValue(string.Empty); cell = row.CreateCell(2); cell.CellStyle = cellStyleR; cell.SetCellValue(string.Empty); cell = row.CreateCell(3); cell.CellStyle = cellStyleR; cell.SetCellValue(string.Empty); cell = row.CreateCell(4); cell.CellStyle = cellStyleR; cell.SetCellValue(string.Empty); cell = row.CreateCell(5); cell.CellStyle = cellStyleR; cell.SetCellValue(string.Empty); cell = row.CreateCell(6); cell.CellStyle = cellStyleR; cell.SetCellValue(string.Empty); cell = row.CreateCell(7); cell.CellStyle = cellStyleR; cell.SetCellValue(string.Empty); sheet.AddMergedRegion(new CellRangeAddress(i, i, 0, 7)); i++; row = sheet.CreateRow(i); cell = row.CreateCell(0); cell.CellStyle = cellStyle; cell.SetCellValue("工程名称"); cell = row.CreateCell(1); cell.CellStyle = cellStyle; var project = BLL.ProjectService.GetProjectByProjectId(constructionLog.ProjectId); cell.SetCellValue(project.ProjectName); cell = row.CreateCell(2); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(3); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(4); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); sheet.AddMergedRegion(new CellRangeAddress(i, i, 1, 4)); cell = row.CreateCell(5); cell.CellStyle = cellStyle; cell.SetCellValue("气候"); cell = row.CreateCell(6); cell.CellStyle = cellStyle; cell.SetCellValue(constructionLog.Weather); cell = row.CreateCell(7); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); sheet.AddMergedRegion(new CellRangeAddress(i, i, 6, 7)); i++; row = sheet.CreateRow(i); cell = row.CreateCell(0); cell.CellStyle = cellStyle; cell.SetCellValue("项目号"); cell = row.CreateCell(1); cell.CellStyle = cellStyle; cell.SetCellValue(project.ProjectCode); cell = row.CreateCell(2); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(3); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(4); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); sheet.AddMergedRegion(new CellRangeAddress(i, i, 1, 4)); cell = row.CreateCell(5); cell.CellStyle = cellStyle; cell.SetCellValue("气温"); cell = row.CreateCell(6); cell.CellStyle = cellStyle; cell.SetCellValue("白天最高" + constructionLog.DayTemperature + "℃ 夜间最低" + constructionLog.NightTemperature + "℃"); cell = row.CreateCell(7); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); sheet.AddMergedRegion(new CellRangeAddress(i, i, 6, 7)); i++; //换行length为54 foreach (var item in lists) { row = sheet.CreateRow(i); cell = row.CreateCell(0); cell.CellStyle = cellStyle; cell.SetCellValue("施工单位"); cell = row.CreateCell(1); cell.CellStyle = cellStyle; //int len = "南通华通建设集团有限公司南通华通建设集团有限公司南通华通建设集团有限公司南通华通建设集团有限公司南通华通建设".Length; //string str = BLL.UnitService.GetUnitNameByUnitId(item.UnitId) + BLL.UnitService.GetUnitNameByUnitId(item.UnitId) + BLL.UnitService.GetUnitNameByUnitId(item.UnitId) + BLL.UnitService.GetUnitNameByUnitId(item.UnitId) + BLL.UnitService.GetUnitNameByUnitId(item.UnitId) + BLL.UnitService.GetUnitNameByUnitId(item.UnitId) + BLL.UnitService.GetUnitNameByUnitId(item.UnitId); //double h = Math.Ceiling(str.Length / 54.0); //if (h > 1) //{ // row.Height = (short)(h * 260); //} cell.SetCellValue(BLL.UnitService.GetUnitNameByUnitId(item.UnitId)); cell = row.CreateCell(2); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(3); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(4); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(5); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(6); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(7); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); sheet.AddMergedRegion(new CellRangeAddress(i, i, 1, 7)); i++; row = sheet.CreateRow(i); cell = row.CreateCell(0); cell.CellStyle = cellStyle; cell.SetCellValue("工程形象进度及工作情况"); cell = row.CreateCell(1); cell.CellStyle = cellStyle; cell.SetCellValue("工作形象进度描述"); cell = row.CreateCell(2); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(3); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(4); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(5); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(6); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(7); cell.CellStyle = cellStyle; cell.SetCellValue("形象图片"); sheet.AddMergedRegion(new CellRangeAddress(i, i, 1, 6)); var imgList = BLL.CQMSConstructionLogImageProgressService.GetConstructionLogImageProgressByConstructionLogIdAndUnitId(constructionLogId, item.UnitId); foreach (var img in imgList) { i++; row = sheet.CreateRow(i); cell = row.CreateCell(0); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(1); cell.CellStyle = cellStyle; cell.SetCellValue(img.ImageProgressDef); cell = row.CreateCell(2); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(3); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(4); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(5); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(6); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(7); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); var attachFile1 = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == img.ConstructionLogImageProgressId); if (attachFile1 != null) { string fp = BLL.Funs.RootPath + attachFile1.AttachUrl; byte[] fileBytes = File.ReadAllBytes(fp); System.Drawing.Image myimage = System.Drawing.Image.FromFile(fp); System.Drawing.Size size = new System.Drawing.Size(myimage.Width, myimage.Height); TryAddPicture(sheet, i, 7, fileBytes, size.Width, size.Height, PictureType.PNG); } row.Height = (short)(4 * 260); sheet.AddMergedRegion(new CellRangeAddress(i, i, 1, 6)); } if (imgList.Count > 0) { sheet.AddMergedRegion(new CellRangeAddress(i - imgList.Count, i, 0, 0)); } i++; row = sheet.CreateRow(i); cell = row.CreateCell(0); cell.CellStyle = cellStyle; cell.SetCellValue("施工动态信息"); cell = row.CreateCell(1); cell.CellStyle = cellStyle; string personStr = string.Empty; if (item.MechanicNum1 != null || item.MechanicNum2 != null || item.MechanicNum3 != null || item.MechanicNum4 != null || item.MechanicNum5 != null || item.MechanicNum6 != null || item.MechanicNum7 != null || item.MechanicNum8 != null || item.MechanicNum9 != null || item.MechanicNum10 != null || item.MechanicNum11 != null || item.MechanicNum12 != null || item.MechanicNum13 != null || item.MechanicNum14 != null || item.MechanicNum15 != null || item.MechanicNum16 != null || item.MechanicNum17 != null) { personStr += "(其中:"; if (item.MechanicNum1 != null) { personStr += "测量员:" + item.MechanicNum1.ToString() + "人,"; } if (item.MechanicNum2 != null) { personStr += "脚手架工:" + item.MechanicNum2.ToString() + "人,"; } if (item.MechanicNum3 != null) { personStr += "钢筋工:" + item.MechanicNum3.ToString() + "人,"; } if (item.MechanicNum4 != null) { personStr += "木工:" + item.MechanicNum4.ToString() + "人,"; } if (item.MechanicNum5 != null) { personStr += "砼工:" + item.MechanicNum5.ToString() + "人,"; } if (item.MechanicNum6 != null) { personStr += "起重工:" + item.MechanicNum6.ToString() + "人,"; } if (item.MechanicNum7 != null) { personStr += "管工:" + item.MechanicNum7.ToString() + "人,"; } if (item.MechanicNum8 != null) { personStr += "焊工:" + item.MechanicNum8.ToString() + "人,"; } if (item.MechanicNum9 != null) { personStr += "钳工:" + item.MechanicNum9.ToString() + "人,"; } if (item.MechanicNum10 != null) { personStr += "铆工:" + item.MechanicNum10.ToString() + "人,"; } if (item.MechanicNum11 != null) { personStr += "电工:" + item.MechanicNum11.ToString() + "人,"; } if (item.MechanicNum12 != null) { personStr += "仪表工:" + item.MechanicNum12.ToString() + "人,"; } if (item.MechanicNum13 != null) { personStr += "仪表调试工:" + item.MechanicNum13.ToString() + "人,"; } if (item.MechanicNum14 != null) { personStr += "防腐工:" + item.MechanicNum14.ToString() + "人,"; } if (item.MechanicNum15 != null) { personStr += "保温工:" + item.MechanicNum15.ToString() + "人,"; } if (item.MechanicNum16 != null) { personStr += "小工:" + item.MechanicNum16.ToString() + "人,"; } if (item.MechanicNum17 != null) { personStr += "其他工种:" + item.MechanicNum17.ToString() + "人,"; } personStr = personStr.Substring(0, personStr.Length - 1); personStr += ")"; } string person = "1.人员组织: 施工负责人:" + item.ConstructionManager + ",安全监护人:" + item.SafetyGuardian + ",质检员/施工员:" + item.ConstructionWorker + ",技工:" + (item.MechanicNum ?? 0).ToString() + "人" + personStr + ",劳工:" + (item.LabourNum ?? 0).ToString() + "人"; double hperson = Math.Ceiling(person.Length / 54.0); if (hperson > 1) { row.Height = (short)(hperson * 260); } cell.SetCellValue(person); cell = row.CreateCell(2); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(3); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(4); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(5); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(6); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(7); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); sheet.AddMergedRegion(new CellRangeAddress(i, i, 1, 7)); i++; row = sheet.CreateRow(i); cell = row.CreateCell(0); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(1); cell.CellStyle = cellStyle; string mainConstructionMachine = item.MainConstructionMachine; double hMainConstructionMachine = Math.Ceiling(mainConstructionMachine.Length / 54.0); if (hMainConstructionMachine > 1) { row.Height = (short)((hMainConstructionMachine + 1) * 260); } cell.SetCellValue("2.主要施工机械\n" + mainConstructionMachine); cell = row.CreateCell(2); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(3); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(4); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(5); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(6); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(7); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); sheet.AddMergedRegion(new CellRangeAddress(i, i, 1, 7)); i++; row = sheet.CreateRow(i); cell = row.CreateCell(0); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(1); cell.CellStyle = cellStyle; string constructionContent = item.ConstructionContent; double hConstructionContent = Math.Ceiling(constructionContent.Length / 54.0); if (hConstructionContent > 1) { row.Height = (short)((hConstructionContent + 1) * 260); } cell.SetCellValue("3.施工内容\n" + constructionContent); cell = row.CreateCell(2); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(3); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(4); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(5); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(6); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(7); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); sheet.AddMergedRegion(new CellRangeAddress(i, i, 1, 7)); i++; row = sheet.CreateRow(i); cell = row.CreateCell(0); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(1); cell.CellStyle = cellStyle; string constructionEnvironment = item.ConstructionEnvironment; double hConstructionEnvironment = Math.Ceiling(constructionEnvironment.Length / 54.0); if (hConstructionContent > 1) { row.Height = (short)((hConstructionContent + 1) * 260); } cell.SetCellValue("4.施工环境\n" + constructionEnvironment); cell = row.CreateCell(2); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(3); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(4); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(5); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(6); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(7); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); sheet.AddMergedRegion(new CellRangeAddress(i, i, 1, 7)); sheet.AddMergedRegion(new CellRangeAddress(i - 3, i, 0, 0)); i++; row = sheet.CreateRow(i); cell = row.CreateCell(0); cell.CellStyle = cellStyle; cell.SetCellValue("安全措施"); cell = row.CreateCell(1); cell.CellStyle = cellStyle; string safetyWorkSituation = item.SafetyWorkSituation; double hSafetyWorkSituation = Math.Ceiling(safetyWorkSituation.Length / 54.0); if (hSafetyWorkSituation > 1) { row.Height = (short)((hSafetyWorkSituation + 1) * 260); } cell.SetCellValue("1.各相关单位安全管理人员的工作情况\n" + safetyWorkSituation); cell = row.CreateCell(2); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(3); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(4); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(5); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(6); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(7); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); sheet.AddMergedRegion(new CellRangeAddress(i, i, 1, 7)); i++; row = sheet.CreateRow(i); cell = row.CreateCell(0); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(1); cell.CellStyle = cellStyle; string str1 = string.Empty; string[] strs1 = item.SafetyAndQualityMeasures.Split(','); row.Height = (short)(5 * 260); if (strs1.Contains("1")) { str1 += "☑是否按施工作业票施工\n"; } else { str1 += "□是否按施工作业票施工\n"; } if (strs1.Contains("2")) { str1 += "☑按已审批的施工方案进行施工\n"; } else { str1 += "□按已审批的施工方案进行施工\n"; } if (strs1.Contains("3")) { str1 += "☑作业前是否进行安全技术交底\n"; } else { str1 += "□作业前是否进行安全技术交底\n"; } if (strs1.Contains("4")) { str1 += "☑PPE是否齐全"; } else { str1 += "□PPE是否齐全"; } cell.SetCellValue("2.现场安全质量措施\n" + str1); cell = row.CreateCell(2); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(3); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(4); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(5); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(6); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(7); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); sheet.AddMergedRegion(new CellRangeAddress(i, i, 1, 7)); i++; row = sheet.CreateRow(i); cell = row.CreateCell(0); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(1); cell.CellStyle = cellStyle; string str2 = string.Empty; string[] strs2 = item.HabituaViolations.Split(','); row.Height = (short)(4 * 260); if (strs2.Contains("1")) { str2 += "☑不正确佩戴安全帽\n"; } else { str2 += "□不正确佩戴安全帽\n"; } if (strs2.Contains("2")) { str2 += "☑高处作业、电工、焊工无证操作\n"; } else { str2 += "□高处作业、电工、焊工无证操作\n"; } if (strs2.Contains("3")) { str2 += "☑焊接作业区域是否有焊接工艺卡\n"; } else { str2 += "□焊接作业区域是否有焊接工艺卡\n"; } cell.SetCellValue("3.现场是否有习惯性违章情况\n" + str2); cell = row.CreateCell(2); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(3); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(4); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(5); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(6); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(7); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); sheet.AddMergedRegion(new CellRangeAddress(i, i, 1, 7)); i++; row = sheet.CreateRow(i); cell = row.CreateCell(0); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(1); cell.CellStyle = cellStyle; string str3 = string.Empty; string[] strs3 = item.SafetyStandardization.Split(','); row.Height = (short)(6 * 260); if (strs3.Contains("1")) { str3 += "☑灭火器\n"; } else { str3 += "□灭火器\n"; } if (strs3.Contains("2")) { str3 += "☑医药箱\n"; } else { str3 += "□医药箱\n"; } if (strs3.Contains("3")) { str3 += "☑安全围栏\n"; } else { str3 += "□安全围栏\n"; } if (strs3.Contains("4")) { str3 += "☑施工提醒牌\n"; } else { str3 += "□施工提醒牌\n"; } if (strs3.Contains("5")) { str3 += "☑现场工器具是否整齐有序\n"; } else { str3 += "□现场工器具是否整齐有序\n"; } cell.SetCellValue("4.现场是否按安全文明标准化进行布置\n" + str3); cell = row.CreateCell(2); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(3); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(4); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(5); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(6); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(7); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); sheet.AddMergedRegion(new CellRangeAddress(i, i, 1, 7)); i++; row = sheet.CreateRow(i); cell = row.CreateCell(0); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(1); cell.CellStyle = cellStyle; string civilizedConstruction = item.CivilizedConstruction; double hCivilizedConstruction = Math.Ceiling(civilizedConstruction.Length / 54.0); if (hCivilizedConstruction > 1) { row.Height = (short)((hCivilizedConstruction + 1) * 260); } cell.SetCellValue("5.文明施工执行情况\n" + civilizedConstruction); cell = row.CreateCell(2); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(3); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(4); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(5); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(6); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(7); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); sheet.AddMergedRegion(new CellRangeAddress(i, i, 1, 7)); sheet.AddMergedRegion(new CellRangeAddress(i - 4, i, 0, 0)); i++; row = sheet.CreateRow(i); cell = row.CreateCell(0); cell.CellStyle = cellStyle; cell.SetCellValue("施工质量"); cell = row.CreateCell(1); cell.CellStyle = cellStyle; string sgzl = string.Empty; string equipment1 = item.Equipment1; double hEquipment1 = Math.Ceiling(equipment1.Length / 54.0); if (hEquipment1 == 0) { hEquipment1 = 1; } string equipment2 = item.Equipment2; double hEquipment2 = Math.Ceiling(equipment2.Length / 54.0); if (hEquipment2 == 0) { hEquipment2 = 1; } string equipment3 = item.Equipment3; double hEquipment3 = Math.Ceiling(equipment3.Length / 54.0); if (hEquipment3 == 0) { hEquipment3 = 1; } string equipment4 = item.Equipment4; double hEquipment4 = Math.Ceiling(equipment4.Length / 54.0); if (hEquipment4 == 0) { hEquipment4 = 1; } string equipment5 = item.Equipment5; double hEquipment5 = Math.Ceiling(equipment5.Length / 54.0); if (hEquipment5 == 0) { hEquipment5 = 1; } string equipment6 = item.Equipment6; double hEquipment6 = Math.Ceiling(equipment6.Length / 54.0); if (hEquipment6 == 0) { hEquipment6 = 1; } string equipment7 = item.Equipment7; double hEquipment7 = Math.Ceiling(equipment7.Length / 54.0); if (hEquipment7 == 0) { hEquipment7 = 1; } row.Height = (short)((hEquipment1 + hEquipment2 + hEquipment3 + hEquipment4 + hEquipment5 + hEquipment6 + hEquipment7 + 8) * 260); cell.SetCellValue("1.原材料、设备到货及初验情况\n1) 到货设备、材料名称\n" + equipment1 + "\n2) 厂家名称\n" + equipment2 + "\n3) 到货数量\n" + equipment3 + "\n4) 到货外观质量情况\n" + equipment4 + "\n5) 随车资料情况\n" + equipment5 + "\n6) 运输车辆车牌号\n" + equipment6 + "\n7) 司机姓名及联系方式\n" + equipment7); cell = row.CreateCell(2); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(3); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(4); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(5); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(6); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(7); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); sheet.AddMergedRegion(new CellRangeAddress(i, i, 1, 7)); i++; row = sheet.CreateRow(i); cell = row.CreateCell(0); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(1); cell.CellStyle = cellStyle; cell.SetCellValue("2.现场质量检查情况"); cell = row.CreateCell(2); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(3); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(4); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(5); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(6); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(7); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); sheet.AddMergedRegion(new CellRangeAddress(i, i, 1, 7)); string strSql = @"SELECT chec.CheckControlCode,chec.CheckSite,chec.ProjectId,chec.unitId,cNProfessional.ProfessionalName," + @" QualityQuestionType.QualityQuestionType as QuestionType," + @" chec.checkman,chec.CheckDate,chec.DocCode,chec.submitman,chec.state,chec.CNProfessionalCode," + @" unit.UnitName,unitWork.UnitWorkName,u.userName " + @" FROM Check_CheckControl chec" + @" left join Base_Unit unit on unit.unitId=chec.unitId" + @" left join Base_CNProfessional cNProfessional on cNProfessional.CNProfessionalId=chec.CNProfessionalCode" + @" left join WBS_UnitWork unitWork on unitWork.UnitWorkId = chec.UnitWorkId" + @" left join Base_QualityQuestionType QualityQuestionType on QualityQuestionType.QualityQuestionTypeId = chec.QuestionType" + @" left join sys_User u on u.userId = chec.CheckMan" + @" where chec.ProjectId=@ProjectId"; List listStr = new List(); listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId)); strSql += " AND chec.CheckDate=@checkTime "; listStr.Add(new SqlParameter("@checkTime", string.Format("{0:yyyy-MM-dd}", date))); strSql += " AND chec.unitId=@unitId"; listStr.Add(new SqlParameter("@unitId", item.UnitId)); SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); if (tb.Rows.Count > 0) { i++; row = sheet.CreateRow(i); cell = row.CreateCell(0); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); 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("检查人"); } for (int j = 0; j < tb.Rows.Count; j++) { i++; row = sheet.CreateRow(i); cell = row.CreateCell(0); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(1); cell.CellStyle = cellStyle; cell.SetCellValue(tb.Rows[j]["UnitWorkName"].ToString()); cell = row.CreateCell(2); cell.CellStyle = cellStyle; cell.SetCellValue(tb.Rows[j]["ProfessionalName"].ToString()); cell = row.CreateCell(3); cell.CellStyle = cellStyle; cell.SetCellValue(tb.Rows[j]["QuestionType"].ToString()); cell = row.CreateCell(4); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); var attachFile1 = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == tb.Rows[j]["CheckControlCode"].ToString()); if (attachFile1 != null) { string fp = BLL.Funs.RootPath + attachFile1.AttachUrl; byte[] fileBytes = File.ReadAllBytes(fp); System.Drawing.Image myimage = System.Drawing.Image.FromFile(fp); System.Drawing.Size size = new System.Drawing.Size(myimage.Width, myimage.Height); TryAddPicture(sheet, i, 4, fileBytes, size.Width, size.Height, PictureType.PNG); } cell = row.CreateCell(5); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); var attachFile2 = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == tb.Rows[j]["CheckControlCode"].ToString() + "r"); if (attachFile2 != null) { string fp = BLL.Funs.RootPath + attachFile2.AttachUrl; byte[] fileBytes = File.ReadAllBytes(fp); System.Drawing.Image myimage = System.Drawing.Image.FromFile(fp); System.Drawing.Size size = new System.Drawing.Size(myimage.Width, myimage.Height); TryAddPicture(sheet, i, 5, fileBytes, size.Width, size.Height, PictureType.PNG); } cell = row.CreateCell(6); cell.CellStyle = cellStyle; cell.SetCellValue(tb.Rows[j]["CheckSite"].ToString()); cell = row.CreateCell(7); cell.CellStyle = cellStyle; cell.SetCellValue(tb.Rows[j]["userName"].ToString()); row.Height = (short)(4 * 260); } i++; row = sheet.CreateRow(i); cell = row.CreateCell(0); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(1); cell.CellStyle = cellStyle; string processHandover = item.ProcessHandover; double hProcessHandover = Math.Ceiling(processHandover.Length / 54.0); if (hProcessHandover > 1) { row.Height = (short)((hProcessHandover + 1) * 260); } cell.SetCellValue("3.工序交接\n" + processHandover); cell = row.CreateCell(2); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(3); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(4); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(5); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(6); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(7); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); sheet.AddMergedRegion(new CellRangeAddress(i, i, 1, 7)); i++; row = sheet.CreateRow(i); cell = row.CreateCell(0); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(1); cell.CellStyle = cellStyle; cell.SetCellValue("4.工程验收"); cell = row.CreateCell(2); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(3); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(4); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(5); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(6); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(7); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); sheet.AddMergedRegion(new CellRangeAddress(i, i, 1, 7)); var inspectionManagement = (from x in Funs.DB.ProcessControl_InspectionManagement where x.InspectionDate.Value.Date == date && x.UnitId == item.UnitId select x).FirstOrDefault(); int row2 = 0; if (inspectionManagement != null) { var list = BLL.InspectionManagementDetailService.GetInspectionDetails(inspectionManagement.InspectionId); if (list.Count > 0) { i++; row = sheet.CreateRow(i); cell = row.CreateCell(0); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); 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(string.Empty); cell = row.CreateCell(4); cell.CellStyle = cellStyle; cell.SetCellValue("控制点内容"); cell = row.CreateCell(5); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(6); cell.CellStyle = cellStyle; cell.SetCellValue("控制点等级"); cell = row.CreateCell(7); cell.CellStyle = cellStyle; cell.SetCellValue("是否合格"); sheet.AddMergedRegion(new CellRangeAddress(i, i, 2, 3)); sheet.AddMergedRegion(new CellRangeAddress(i, i, 4, 5)); foreach (var l in list) { i++; row = sheet.CreateRow(i); cell = row.CreateCell(0); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(1); cell.CellStyle = cellStyle; cell.SetCellValue(ConvertUnitWork(l.UnitWorkId)); cell = row.CreateCell(2); cell.CellStyle = cellStyle; cell.SetCellValue(ConvertBranch(l.Branch)); cell = row.CreateCell(3); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(4); cell.CellStyle = cellStyle; cell.SetCellValue(ConvertControlPointType(l.ControlPointType)); cell = row.CreateCell(5); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(6); cell.CellStyle = cellStyle; cell.SetCellValue(ConvertClass(l.ControlPointType)); cell = row.CreateCell(7); cell.CellStyle = cellStyle; cell.SetCellValue(ConvertOK(l.InspectionId)); sheet.AddMergedRegion(new CellRangeAddress(i, i, 2, 3)); sheet.AddMergedRegion(new CellRangeAddress(i, i, 4, 5)); } } row2 = 1 + list.Count; } i++; row = sheet.CreateRow(i); cell = row.CreateCell(0); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(1); cell.CellStyle = cellStyle; string workArrangement = item.WorkArrangement; double hWorkArrangement = Math.Ceiling(workArrangement.Length / 54.0); if (hWorkArrangement > 1) { row.Height = (short)((hWorkArrangement + 1) * 260); } cell.SetCellValue("5.质量问题整改情况,存在问题及整改工作安排\n" + workArrangement); cell = row.CreateCell(2); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(3); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(4); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(5); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(6); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(7); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); sheet.AddMergedRegion(new CellRangeAddress(i, i, 1, 7)); int row1 = tb.Rows.Count > 0 ? (tb.Rows.Count + 1) : 0; int a = 2 + row1 + 1 + row2 + 1; sheet.AddMergedRegion(new CellRangeAddress(i - a, i, 0, 0)); i++; row = sheet.CreateRow(i); cell = row.CreateCell(0); cell.CellStyle = cellStyle; cell.SetCellValue("其它"); cell = row.CreateCell(1); cell.CellStyle = cellStyle; string meetingSituation = item.MeetingSituation; double hMeetingSituation = Math.Ceiling(meetingSituation.Length / 54.0); if (hMeetingSituation == 0) { hMeetingSituation = 1; } string visaRecords = item.VisaRecords; double hVisaRecords = Math.Ceiling(visaRecords.Length / 54.0); if (hVisaRecords == 0) { hVisaRecords = 1; } string unresolvedIssues = item.UnresolvedIssues; double hUnresolvedIssues = Math.Ceiling(unresolvedIssues.Length / 54.0); if (hUnresolvedIssues == 0) { hUnresolvedIssues = 1; } string fileProcessing = item.FileProcessing; double hFileProcessing = Math.Ceiling(fileProcessing.Length / 54.0); if (hFileProcessing == 0) { hFileProcessing = 1; } string rectificationOfIssues = item.RectificationOfIssues; double hRectificationOfIssues = Math.Ceiling(rectificationOfIssues.Length / 54.0); if (hRectificationOfIssues == 0) { hRectificationOfIssues = 1; } string importantEvents = item.ImportantEvents; double hImportantEvents = Math.Ceiling(importantEvents.Length / 54.0); if (hImportantEvents == 0) { hImportantEvents = 1; } row.Height = (short)((hMeetingSituation + hVisaRecords + hUnresolvedIssues + hFileProcessing + hRectificationOfIssues + hImportantEvents + 7) * 260); cell.SetCellValue("1.参加各种会议,会议主持人,参会单位及主要人员,会议内容,会议结论\n" + meetingSituation + "\n2.签证记录(签证部位、投入人力、使用时间及完成情况)\n" + visaRecords + "\n3.需要专业、部门及上级领导协调解决的问题\n" + unresolvedIssues + "\n4.往来文件处理及计划安排\n" + fileProcessing + "\n5.现场遗留问题的整改情况(对现场发现的有关进度、质量、安全、文明施工等问题的处理情况,包括处理措施和结果,对重大问题的处理应从问题的发生、分析及问题的解决方面做详细记载)\n" + rectificationOfIssues + "\n6.重要事件:事件发生的时间、地点、涉及人员及事件简述\n" + importantEvents); cell = row.CreateCell(2); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(3); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(4); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(5); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(6); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(7); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); sheet.AddMergedRegion(new CellRangeAddress(i, i, 1, 7)); i++; row = sheet.CreateRow(i); cell = row.CreateCell(0); cell.CellStyle = cellStyle; cell.SetCellValue("存在问题及原因分析"); cell = row.CreateCell(1); cell.CellStyle = cellStyle; string problemAndCauseAnalysis = item.ProblemAndCauseAnalysis; double hProblemAndCauseAnalysis = Math.Ceiling(problemAndCauseAnalysis.Length / 54.0); if (hProblemAndCauseAnalysis == 0) { hProblemAndCauseAnalysis = 1; } row.Height = (short)((hProblemAndCauseAnalysis + 1) * 260); cell.SetCellValue("(工作中存在的问题及相应的应对措施)\n" + problemAndCauseAnalysis); cell = row.CreateCell(2); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(3); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(4); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(5); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(6); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(7); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); sheet.AddMergedRegion(new CellRangeAddress(i, i, 1, 7)); i++; } row = sheet.CreateRow(i); cell = row.CreateCell(0); cell.CellStyle = cellStyle; cell.SetCellValue("记录人"); cell = row.CreateCell(1); cell.CellStyle = cellStyle; cell.SetCellValue(compileMan); cell = row.CreateCell(2); cell.CellStyle = cellStyle; cell.SetCellValue("审核"); cell = row.CreateCell(3); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(4); cell.CellStyle = cellStyle; string auditMan = string.Empty; var approve1 = BLL.CQMSConstructionLogApproveService.GetAudit(constructionLogId); if (approve1 != null) { auditMan = BLL.UserService.GetUserNameByUserId(approve1.ApproveMan); } cell.SetCellValue(auditMan); cell = row.CreateCell(5); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(6); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); cell = row.CreateCell(7); cell.CellStyle = cellStyle; cell.SetCellValue(string.Empty); sheet.AddMergedRegion(new CellRangeAddress(i, i, 2, 3)); sheet.AddMergedRegion(new CellRangeAddress(i, i, 4, 7)); // 第三步:写入文件流 using (FileStream stream = new FileStream(newUrl, FileMode.Create, FileAccess.Write)) { workbook.Write(stream); workbook.Close(); } string fileName = Path.GetFileName(newUrl); FileInfo info = new FileInfo(newUrl); long fileSize = info.Length; Response.Clear(); Response.ContentType = "application/x-zip-compressed"; Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8)); Response.AddHeader("Content-Length", fileSize.ToString()); Response.TransmitFile(newUrl, 0, fileSize); Response.Flush(); Response.Close(); File.Delete(newUrl); } else { Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning); return; } } } private void TryAddPicture(ISheet sheet, int row, int col, byte[] pictureBytes, int Wpx, int Hpx, PictureType pictureType = PictureType.PNG) { if (sheet is null) { throw new ArgumentNullException(nameof(sheet)); } try { var pictureIndex = sheet.Workbook.AddPicture(pictureBytes, pictureType); var clientAnchor = sheet.Workbook.GetCreationHelper().CreateClientAnchor(); clientAnchor.Row1 = row; clientAnchor.Col1 = col; var picture = (sheet.DrawingPatriarch ?? sheet.CreateDrawingPatriarch()) .CreatePicture(clientAnchor, pictureIndex); if (Wpx != 0 && Hpx != 0) { double w = Wpx / 1; double h = Hpx / 1.05; picture.Resize(Wpx / w, Hpx / h); } else { picture.Resize(); } } catch (Exception ex) { } } #region 转换字符串 /// /// 获取单位工程 /// /// /// protected string ConvertUnitWork(object UnitWorkId) { string name = string.Empty; if (UnitWorkId != null) { Model.WBS_UnitWork unitWork = BLL.UnitWorkService.GetUnitWorkByUnitWorkId(UnitWorkId.ToString()); if (unitWork != null) { name = unitWork.UnitWorkName; } } return name; } /// /// 获取分部 /// /// /// protected 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; } /// /// 获取控制点内容 /// /// /// protected 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; } /// /// 获取控制点等级 /// /// /// protected 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; } /// /// 获取是否合格 /// /// /// protected string ConvertOK(object InspectionId) { string name = string.Empty; if (InspectionId != null) { var inspection = BLL.InspectionManagementService.GetInspectionManagementById(InspectionId.ToString()); if (inspection != null) { if (inspection.IsOnceQualified == true) { name = "是"; } else { name = "否"; } } } return name; } #endregion } }