1质量巡检导出补充无图导出功能

This commit is contained in:
2025-04-25 15:58:41 +08:00
parent 6bebbe15ef
commit b66d6aeba3
3 changed files with 163 additions and 154 deletions
+93 -95
View File
@@ -6,7 +6,7 @@ using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Text;
using System.Text;
using System.Threading.Tasks;
using NPOI.SS.UserModel;
@@ -402,26 +402,26 @@ namespace FineUIPro.Web.CQMS.Check
{
bool isAuthenticated = false;
var query = (from pu in Funs.DB.Project_ProjectUser
join u in Funs.DB.Sys_User on pu.UserId equals u.UserId into userGroup
from u in userGroup.DefaultIfEmpty()
join projectUnit in Funs.DB.Project_ProjectUnit on new { pu.UnitId, pu.ProjectId }
equals new { projectUnit.UnitId, projectUnit.ProjectId } into projectUnitJoin
from projectUnit in projectUnitJoin.DefaultIfEmpty()
join person in Funs.DB.SitePerson_Person on new { pu.ProjectId, u.IdentityCard } equals new
{ person.ProjectId, person.IdentityCard } into personGroup
from person in personGroup.DefaultIfEmpty()
join wp in Funs.DB.Base_WorkPost on person.WorkPostId equals wp.WorkPostId into workPostGroup
from wp in workPostGroup.DefaultIfEmpty()
join sysConst in Funs.DB.Sys_Const on new
{ GroupId = "ProjectUnitType", ConstValue = projectUnit.UnitType } equals new
{ sysConst.GroupId, sysConst.ConstValue } into sysConstJoin
from sysConst in sysConstJoin.DefaultIfEmpty()
where pu.ProjectId == this.ProjectId && pu.UserId == this.CurrUser.UserId && sysConst.ConstText == "总包"
select new
{
pu.RoleId,
wp.WorkPostName,
}).FirstOrDefault();
join u in Funs.DB.Sys_User on pu.UserId equals u.UserId into userGroup
from u in userGroup.DefaultIfEmpty()
join projectUnit in Funs.DB.Project_ProjectUnit on new { pu.UnitId, pu.ProjectId }
equals new { projectUnit.UnitId, projectUnit.ProjectId } into projectUnitJoin
from projectUnit in projectUnitJoin.DefaultIfEmpty()
join person in Funs.DB.SitePerson_Person on new { pu.ProjectId, u.IdentityCard } equals new
{ person.ProjectId, person.IdentityCard } into personGroup
from person in personGroup.DefaultIfEmpty()
join wp in Funs.DB.Base_WorkPost on person.WorkPostId equals wp.WorkPostId into workPostGroup
from wp in workPostGroup.DefaultIfEmpty()
join sysConst in Funs.DB.Sys_Const on new
{ GroupId = "ProjectUnitType", ConstValue = projectUnit.UnitType } equals new
{ sysConst.GroupId, sysConst.ConstValue } into sysConstJoin
from sysConst in sysConstJoin.DefaultIfEmpty()
where pu.ProjectId == this.ProjectId && pu.UserId == this.CurrUser.UserId && sysConst.ConstText == "总包"
select new
{
pu.RoleId,
wp.WorkPostName,
}).FirstOrDefault();
List<string> names = new List<string>();
if (query != null)
{
@@ -434,7 +434,7 @@ namespace FineUIPro.Web.CQMS.Check
});
var RoleName = string.Join(",", names);
if (RoleName.Contains("质量") || RoleName.Contains("施工") )
if (RoleName.Contains("质量") || RoleName.Contains("施工"))
{
isAuthenticated = true;
}
@@ -442,9 +442,9 @@ namespace FineUIPro.Web.CQMS.Check
return isAuthenticated;
}
#endregion
#region
@@ -734,7 +734,7 @@ namespace FineUIPro.Web.CQMS.Check
// cell = row.CreateCell(0);
// cell.CellStyle = cellStyle;
// cell.SetCellValue(item.DocCode);//质量巡检编号
cell = row.CreateCell(0);
cell.CellStyle = cellStyle;
cell.SetCellValue(item.CheckDate.HasValue ? string.Format("{0:yyyy-MM-dd}", item.CheckDate) : "");//检查日期
@@ -784,93 +784,91 @@ namespace FineUIPro.Web.CQMS.Check
if (!string.IsNullOrEmpty(item.QuestionType))
{
var qt = Funs.DB.Base_QualityQuestionType.FirstOrDefault(x => x.QualityQuestionTypeId == item.QuestionType);
if (qt!=null)
if (qt != null)
{
t = qt.QualityQuestionType;
}
}
cell.SetCellValue(t);//问题类别
// cell = row.CreateCell(5);
// cell.CellStyle = cellStyle;
// cell.SetCellValue(item.CheckSite);//整改前照片
//整改前照片
var attachFile = Funs.DB.AttachFile
.Where(p => p.MenuId == BLL.Const.CheckListMenuId && p.ToKeyId == item.CheckControlCode)
.FirstOrDefault();
if (attachFile != null)
{
var photoesUrl = attachFile.AttachUrl;
if (photoesUrl != null)
{
string[] arrUrl = photoesUrl.Split(',');
sheet.SetColumnWidth(5, 30 * 256);
row.Height = (short)(90 * 20 * arrUrl.Length);
foreach (string url in arrUrl)
{
var oneUrl = Server.MapPath("~/") + url;
byte[] bytes = System.IO.File.ReadAllBytes(oneUrl);
int pictureIdx = workbook.AddPicture(bytes, PictureType.JPEG);
if (rbOutType.SelectedValue == "1")
{//导出带图片
// 第三步:创建画部
IDrawing patriarch = sheet.CreateDrawingPatriarch();
// 第四步:设置锚点
int rowline = 1; // y方向
// 参数说明:(在起始单元格的X坐标0-1023,Y的坐标0-255,在终止单元格的X坐标0-1023,Y的坐标0-255,起始单元格列数,行数,终止单元格列数,行数)
IClientAnchor anchor = patriarch.CreateAnchor(0, 0, 0, 0, 5, i, 6, i + 1);
// 第五步:把图片插到相应的位置+1
IPicture pict = patriarch.CreatePicture(anchor, pictureIdx);
//就取第一张,如果后期想取全部 那把下面这个跳出语句去掉
// break;
//整改前照片
var attachFile = Funs.DB.AttachFile.Where(p => p.MenuId == BLL.Const.CheckListMenuId && p.ToKeyId == item.CheckControlCode).FirstOrDefault();
if (attachFile != null)
{
var photoesUrl = attachFile.AttachUrl;
if (photoesUrl != null)
{
string[] arrUrl = photoesUrl.Split(',');
sheet.SetColumnWidth(5, 30 * 256);
row.Height = (short)(90 * 20 * arrUrl.Length);
foreach (string url in arrUrl)
{
var oneUrl = Server.MapPath("~/") + url;
byte[] bytes = System.IO.File.ReadAllBytes(oneUrl);
int pictureIdx = workbook.AddPicture(bytes, PictureType.JPEG);
// 第三步:创建画部
IDrawing patriarch = sheet.CreateDrawingPatriarch();
// 第四步:设置锚点
int rowline = 1; // y方向
// 参数说明:(在起始单元格的X坐标0-1023,Y的坐标0-255,在终止单元格的X坐标0-1023,Y的坐标0-255,起始单元格列数,行数,终止单元格列数,行数)
IClientAnchor anchor = patriarch.CreateAnchor(0, 0, 0, 0, 5, i, 6, i + 1);
// 第五步:把图片插到相应的位置+1
IPicture pict = patriarch.CreatePicture(anchor, pictureIdx);
//就取第一张,如果后期想取全部 那把下面这个跳出语句去掉
// break;
}
}
}
}
//整改后照片
var attachFile1 = Funs.DB.AttachFile.Where(p =>
p.MenuId == BLL.Const.CheckListMenuId && p.ToKeyId == item.CheckControlCode + "r")
.FirstOrDefault();
if (attachFile1 != null)
{
var photoesUrl1 = attachFile1.AttachUrl;
if (photoesUrl1 != null)
//整改后照片
var attachFile1 = Funs.DB.AttachFile.Where(p => p.MenuId == BLL.Const.CheckListMenuId && p.ToKeyId == item.CheckControlCode + "r").FirstOrDefault();
if (attachFile1 != null)
{
string[] arrUrl = photoesUrl1.Split(',');
sheet.SetColumnWidth(6, 30 * 256);
row.Height = (short)(90 * 20 * arrUrl.Length);
foreach (string url in arrUrl)
var photoesUrl1 = attachFile1.AttachUrl;
if (photoesUrl1 != null)
{
var oneUrl = Server.MapPath("~/") + url;
byte[] bytes = System.IO.File.ReadAllBytes(oneUrl);
int pictureIdx = workbook.AddPicture(bytes, PictureType.JPEG);
string[] arrUrl = photoesUrl1.Split(',');
sheet.SetColumnWidth(6, 30 * 256);
row.Height = (short)(90 * 20 * arrUrl.Length);
foreach (string url in arrUrl)
{
var oneUrl = Server.MapPath("~/") + url;
byte[] bytes = System.IO.File.ReadAllBytes(oneUrl);
int pictureIdx = workbook.AddPicture(bytes, PictureType.JPEG);
// 第三步:创建画部
IDrawing patriarch = sheet.CreateDrawingPatriarch();
// 第四步:设置锚点
int rowline = 1; // y方向
// 参数说明:(在起始单元格的X坐标0-1023,Y的坐标0-255,在终止单元格的X坐标0-1023,Y的坐标0-255,起始单元格列数,行数,终止单元格列数,行数)
IClientAnchor anchor = patriarch.CreateAnchor(0, 0, 0, 0, 6, i, 7, i + 1);
// 第五步:把图片插到相应的位置+1
IPicture pict = patriarch.CreatePicture(anchor, pictureIdx);
//就取第一张,如果后期想取全部 那把下面这个跳出语句去掉
// break;
// 第三步:创建画部
IDrawing patriarch = sheet.CreateDrawingPatriarch();
// 第四步:设置锚点
int rowline = 1; // y方向
// 参数说明:(在起始单元格的X坐标0-1023,Y的坐标0-255,在终止单元格的X坐标0-1023,Y的坐标0-255,起始单元格列数,行数,终止单元格列数,行数)
IClientAnchor anchor = patriarch.CreateAnchor(0, 0, 0, 0, 6, i, 7, i + 1);
// 第五步:把图片插到相应的位置+1
IPicture pict = patriarch.CreatePicture(anchor, pictureIdx);
//就取第一张,如果后期想取全部 那把下面这个跳出语句去掉
// break;
}
}
}
}
else
{
cell = row.CreateCell(5);
cell.CellStyle = cellStyle;
cell.SetCellValue("");//整改前图片
cell = row.CreateCell(6);
cell.CellStyle = cellStyle;
cell.SetCellValue("");//整改后图片
}
// cell = row.CreateCell(6);
// cell.CellStyle = cellStyle;
// cell.SetCellValue(item.CheckSite);//整改后照片
// cell = row.CreateCell(5);
// cell.CellStyle = cellStyle;
// cell.SetCellValue(item.CheckSite);//部位
cell = row.CreateCell(7);
cell.CellStyle = cellStyle;
cell.SetCellValue(item.QuestionDef);//问题描述
cell = row.CreateCell(8);
cell.CellStyle = cellStyle;
cell.SetCellValue(item.RectifyOpinion);//整改意见
@@ -935,7 +933,7 @@ namespace FineUIPro.Web.CQMS.Check
}
}
#endregion
/// <summary>
/// 获取整改前图片(放于Img中)
/// </summary>
@@ -954,7 +952,7 @@ namespace FineUIPro.Web.CQMS.Check
}
return url;
}
/// <summary>
/// 获取整改后图片(放于Img中)
/// </summary>