20240429 修改综合管理导入导出

This commit is contained in:
2024-04-29 19:13:54 +08:00
parent fc56b1f6c2
commit a3e123957d
48 changed files with 560 additions and 266 deletions
@@ -282,7 +282,7 @@ namespace FineUIPro.Web.Comprehensive
protected void btnOut_Click(object sender, EventArgs e)
{
string rootPath = Server.MapPath("~/");
string initTemplatePath = Const.InspectionEquipmentTempUrl;
string initTemplatePath = Const.InspectionEquipmentDataInUrl;
string uploadfilepath = string.Empty;
string newUrl = string.Empty;
uploadfilepath = rootPath + initTemplatePath;
@@ -306,10 +306,11 @@ namespace FineUIPro.Web.Comprehensive
{
lists = lists.Where(x => x.InspectionDate <= Funs.GetNewDateTime(txtEndTime.Text.Trim()));
}
lists = lists.OrderBy(x => x.UnitId);
lists = lists.OrderBy(x => x.RemarkCode);
if (lists != null)
{
newUrl = uploadfilepath.Replace("设备材料报验模板.xls", "设备材料报验.xls");
var projectName = BLL.ProjectService.GetProjectNameByProjectId(this.CurrUser.LoginProjectId);
newUrl = uploadfilepath.Replace("设备材料报验导入模板", "设备材料报验(" + projectName + "" + DateTime.Now.ToString("yyyyMMdd") + ")");
File.Copy(uploadfilepath, newUrl);
// 第一步:读取文件流
NPOI.SS.UserModel.IWorkbook workbook;
@@ -344,7 +345,7 @@ namespace FineUIPro.Web.Comprehensive
NPOI.SS.UserModel.ISheet sheet = workbook.GetSheetAt(0);
NPOI.SS.UserModel.IRow row = sheet.GetRow(0);
NPOI.SS.UserModel.ICell cell;
int i = 1;
int i = 2;
foreach (var item in lists)
{
// 第二步:创建新数据行
@@ -360,10 +361,6 @@ namespace FineUIPro.Web.Comprehensive
cell = row.CreateCell(2);
cell.CellStyle = cellStyle;
cell.SetCellValue(item.EquipmentNO);//设备位号
cell = row.CreateCell(3);
cell.CellStyle = cellStyle;
var cnp = BLL.CNProfessionalService.GetCNProfessional(item.CNProfessionalId);
if (cnp != null)
{
@@ -374,6 +371,10 @@ namespace FineUIPro.Web.Comprehensive
cell.SetCellValue(string.Empty);//专业
}
cell = row.CreateCell(3);
cell.CellStyle = cellStyle;
cell.SetCellValue(item.EquipmentNO);//设备位号
cell = row.CreateCell(4);
cell.CellStyle = cellStyle;
cell.SetCellValue(item.InspectionName);//名称
@@ -422,6 +423,10 @@ namespace FineUIPro.Web.Comprehensive
cell.CellStyle = cellStyle;
cell.SetCellValue(item.UsedPlace);//拟使用部位
cell = row.CreateCell(13);
cell.CellStyle = cellStyle;
cell.SetCellValue(item.RemarkCode.HasValue ? item.RemarkCode.ToString() : "");//标志编号
i++;
}
// 第三步:写入文件流