设备数采项目刷选 工艺标准模板导出
This commit is contained in:
16
EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipDaqQueryOutput.cs
Normal file
16
EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipDaqQueryOutput.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
namespace Tnb.EquipMgr.Entities.Dto
|
||||||
|
{
|
||||||
|
public class EquipDaqQueryOutput
|
||||||
|
{
|
||||||
|
public string id { get; set; }
|
||||||
|
public string data_source { get; set; }
|
||||||
|
public string create_id { get; set; }
|
||||||
|
public string create_time { get; set; }
|
||||||
|
public string data_type { get; set; }
|
||||||
|
public string enabled { get; set; }
|
||||||
|
public string equip_id { get; set; }
|
||||||
|
public string label_name { get; set; }
|
||||||
|
public string label_point { get; set; }
|
||||||
|
public string remark { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
87
EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpDaq.cs
Normal file
87
EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpDaq.cs
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
using JNPF.Common.Contracts;
|
||||||
|
using JNPF.Common.Security;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace Tnb.EquipMgr.Entities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 数据采集项目
|
||||||
|
/// </summary>
|
||||||
|
[SugarTable("eqp_daq")]
|
||||||
|
public partial class EqpDaq : BaseEntity<string>
|
||||||
|
{
|
||||||
|
public EqpDaq()
|
||||||
|
{
|
||||||
|
id = SnowflakeIdHelper.NextId();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 数据源
|
||||||
|
/// </summary>
|
||||||
|
public string data_source { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标签名称
|
||||||
|
/// </summary>
|
||||||
|
public string? label_name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标签点位
|
||||||
|
/// </summary>
|
||||||
|
public string? label_point { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 数据类型
|
||||||
|
/// </summary>
|
||||||
|
public string? data_type { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否启用
|
||||||
|
/// </summary>
|
||||||
|
public int? enabled { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 备注
|
||||||
|
/// </summary>
|
||||||
|
public string? remark { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建用户
|
||||||
|
/// </summary>
|
||||||
|
public string? create_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? create_time { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修改用户
|
||||||
|
/// </summary>
|
||||||
|
public string? modify_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修改时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? modify_time { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 所属组织
|
||||||
|
/// </summary>
|
||||||
|
public string? org_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设备id
|
||||||
|
/// </summary>
|
||||||
|
public string equip_id { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 流程任务Id
|
||||||
|
/// </summary>
|
||||||
|
public string? f_flowtaskid { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 流程引擎Id
|
||||||
|
/// </summary>
|
||||||
|
public string? f_flowid { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
12
EquipMgr/Tnb.EquipMgr.Interfaces/IEqpDaqService.cs
Normal file
12
EquipMgr/Tnb.EquipMgr.Interfaces/IEqpDaqService.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
using Tnb.EquipMgr.Entities.Dto;
|
||||||
|
namespace Tnb.EquipMgr.Interfaces
|
||||||
|
{
|
||||||
|
public interface IEqpDaqService
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 根据设备id获取数采项目
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Task<dynamic> GetEquipDaqList(EquipQueryInput input);
|
||||||
|
}
|
||||||
|
}
|
||||||
63
EquipMgr/Tnb.EquipMgr/EqpDaqService.cs
Normal file
63
EquipMgr/Tnb.EquipMgr/EqpDaqService.cs
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
using JNPF.Common.Core.Manager;
|
||||||
|
using JNPF.Common.Filter;
|
||||||
|
using JNPF.DependencyInjection;
|
||||||
|
using JNPF.DynamicApiController;
|
||||||
|
using JNPF.Systems.Entitys.Permission;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using SqlSugar;
|
||||||
|
using Tnb.EquipMgr.Entities;
|
||||||
|
using Tnb.EquipMgr.Entities.Dto;
|
||||||
|
using Tnb.EquipMgr.Interfaces;
|
||||||
|
|
||||||
|
namespace Tnb.EquipMgr
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 设备数采项目
|
||||||
|
/// </summary>
|
||||||
|
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
||||||
|
[Route("api/[area]/[controller]/[action]")]
|
||||||
|
public class EqpDaqService : IEqpDaqService, IDynamicApiController, ITransient
|
||||||
|
{
|
||||||
|
private readonly ISqlSugarRepository<EqpDaq> _repository;
|
||||||
|
private readonly IUserManager _userManager;
|
||||||
|
|
||||||
|
public EqpDaqService(ISqlSugarRepository<EqpDaq> repository, IUserManager userManager)
|
||||||
|
{
|
||||||
|
_userManager = userManager;
|
||||||
|
_repository = repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<dynamic> GetEquipDaqList(EquipQueryInput input)
|
||||||
|
{
|
||||||
|
var db = _repository.AsSugarClient();
|
||||||
|
Dictionary<string, string> queryJson = new Dictionary<string, string>();
|
||||||
|
if (!string.IsNullOrEmpty(input.queryJson))
|
||||||
|
{
|
||||||
|
queryJson = JsonConvert.DeserializeObject<Dictionary<string, string>>(input.queryJson);
|
||||||
|
}
|
||||||
|
var result = await db.Queryable<EqpDaq>()
|
||||||
|
.LeftJoin<UserEntity>((a,b)=>a.create_id==b.Id)
|
||||||
|
.Where(a=>a.equip_id==input.equip_id)
|
||||||
|
.WhereIF(queryJson.ContainsKey("data_source"),a=>a.data_source==queryJson["data_source"])
|
||||||
|
.WhereIF(queryJson.ContainsKey("label_name"),a=>a.label_name.Contains(queryJson["label_name"]))
|
||||||
|
.WhereIF(queryJson.ContainsKey("label_point"),a=>a.label_point.Contains(queryJson["label_point"]))
|
||||||
|
.Select((a,b) => new EquipDaqQueryOutput
|
||||||
|
{
|
||||||
|
id = a.id,
|
||||||
|
data_source = a.data_source,
|
||||||
|
create_id = b.RealName,
|
||||||
|
create_time = a.create_time.Value.ToString("yyyy-MM-dd HH:mm"),
|
||||||
|
data_type = a.data_type,
|
||||||
|
enabled = a.enabled==1 ? "是" : "否",
|
||||||
|
equip_id = a.equip_id,
|
||||||
|
label_name = a.label_name,
|
||||||
|
label_point = a.label_point,
|
||||||
|
remark = a.remark
|
||||||
|
}).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||||
|
|
||||||
|
return PageResult<EquipDaqQueryOutput>.SqlSugarPageResult(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using JNPF.Common.Core.Manager;
|
using JNPF.Common.Core.Manager;
|
||||||
using JNPF.Common.Dtos.VisualDev;
|
using JNPF.Common.Dtos.VisualDev;
|
||||||
using JNPF.Common.Enums;
|
using JNPF.Common.Enums;
|
||||||
|
using JNPF.Common.Security;
|
||||||
using JNPF.DependencyInjection;
|
using JNPF.DependencyInjection;
|
||||||
using JNPF.DynamicApiController;
|
using JNPF.DynamicApiController;
|
||||||
using JNPF.FriendlyException;
|
using JNPF.FriendlyException;
|
||||||
@@ -41,6 +42,7 @@ namespace Tnb.EquipMgr
|
|||||||
var db = _repository.AsSugarClient();
|
var db = _repository.AsSugarClient();
|
||||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||||
{
|
{
|
||||||
|
eqpEquipScrap.id = SnowflakeIdHelper.NextId();
|
||||||
eqpEquipScrap.create_id = _userManager.UserId;
|
eqpEquipScrap.create_id = _userManager.UserId;
|
||||||
eqpEquipScrap.create_time = DateTime.Now;
|
eqpEquipScrap.create_time = DateTime.Now;
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ using Tnb.EquipMgr.Interfaces;
|
|||||||
|
|
||||||
namespace Tnb.EquipMgr
|
namespace Tnb.EquipMgr
|
||||||
{
|
{
|
||||||
/// 设备备品备件
|
/// <summary>
|
||||||
|
/// 设备技术参数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
||||||
[Route("api/[area]/[controller]/[action]")]
|
[Route("api/[area]/[controller]/[action]")]
|
||||||
|
|||||||
67
PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessParamType.cs
Normal file
67
PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessParamType.cs
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
using JNPF.Common.Contracts;
|
||||||
|
using JNPF.Common.Security;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace Tnb.PerMgr.Entities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 工艺参数类型
|
||||||
|
/// </summary>
|
||||||
|
[SugarTable("per_process_param_type")]
|
||||||
|
public partial class PerProcessParamType : BaseEntity<string>
|
||||||
|
{
|
||||||
|
public PerProcessParamType()
|
||||||
|
{
|
||||||
|
id = SnowflakeIdHelper.NextId();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 名称
|
||||||
|
/// </summary>
|
||||||
|
public string name { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设备类型id
|
||||||
|
/// </summary>
|
||||||
|
public string equip_type_id { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 排序
|
||||||
|
/// </summary>
|
||||||
|
public long ordinal { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建用户
|
||||||
|
/// </summary>
|
||||||
|
public string? create_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修改用户
|
||||||
|
/// </summary>
|
||||||
|
public string? modify_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 所属组织
|
||||||
|
/// </summary>
|
||||||
|
public string? org_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修改时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? modify_time { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? create_time { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 流程任务Id
|
||||||
|
/// </summary>
|
||||||
|
public string? f_flowtaskid { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 流程引擎Id
|
||||||
|
/// </summary>
|
||||||
|
public string? f_flowid { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
107
PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessStandardsH.cs
Normal file
107
PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessStandardsH.cs
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
using JNPF.Common.Contracts;
|
||||||
|
using JNPF.Common.Security;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace Tnb.PerMgr.Entities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 工艺标准
|
||||||
|
/// </summary>
|
||||||
|
[SugarTable("per_process_standards_h")]
|
||||||
|
public partial class PerProcessStandardsH : BaseEntity<string>
|
||||||
|
{
|
||||||
|
public PerProcessStandardsH()
|
||||||
|
{
|
||||||
|
id = SnowflakeIdHelper.NextId();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 工艺类型
|
||||||
|
/// </summary>
|
||||||
|
public string process_type { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 编号
|
||||||
|
/// </summary>
|
||||||
|
public string code { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 工艺文件名
|
||||||
|
/// </summary>
|
||||||
|
public string? file_name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否启用
|
||||||
|
/// </summary>
|
||||||
|
public int? enabled { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 产出物料id
|
||||||
|
/// </summary>
|
||||||
|
public string? output_material_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设备id
|
||||||
|
/// </summary>
|
||||||
|
public string equip_id { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 模具id
|
||||||
|
/// </summary>
|
||||||
|
public string? molds_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 工序id
|
||||||
|
/// </summary>
|
||||||
|
public string? process_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 投入物料id
|
||||||
|
/// </summary>
|
||||||
|
public string? input_material_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 版本号
|
||||||
|
/// </summary>
|
||||||
|
public string version { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建用户
|
||||||
|
/// </summary>
|
||||||
|
public string? create_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? create_time { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修改用户
|
||||||
|
/// </summary>
|
||||||
|
public string? modify_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修改时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? modify_time { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 所属组织
|
||||||
|
/// </summary>
|
||||||
|
public string? org_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 备注
|
||||||
|
/// </summary>
|
||||||
|
public string? remark { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 流程任务Id
|
||||||
|
/// </summary>
|
||||||
|
public string? f_flowtaskid { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 流程引擎Id
|
||||||
|
/// </summary>
|
||||||
|
public string? f_flowid { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Tnb.PerMgr.Entities.Dto;
|
using Tnb.PerMgr.Entities.Dto;
|
||||||
|
|
||||||
namespace Tnb.PerMgr.Interfaces
|
namespace Tnb.PerMgr.Interfaces
|
||||||
@@ -10,5 +11,6 @@ namespace Tnb.PerMgr.Interfaces
|
|||||||
/// <param name="dic"></param>
|
/// <param name="dic"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Task<ProcessParamOutput> GetProcessParamInfo(Dictionary<string,string> dic);
|
public Task<ProcessParamOutput> GetProcessParamInfo(Dictionary<string,string> dic);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
13
PerMgr/Tnb.PerMgr.Interfaces/IPerProcessStandardsService.cs
Normal file
13
PerMgr/Tnb.PerMgr.Interfaces/IPerProcessStandardsService.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace Tnb.PerMgr.Interfaces
|
||||||
|
{
|
||||||
|
public interface IPerProcessStandardsService
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 导出模板
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Task<IActionResult> ExportTemplate();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,12 @@
|
|||||||
using JNPF.Common.Core.Manager;
|
using JNPF.Common.Core.Manager;
|
||||||
using JNPF.DependencyInjection;
|
using JNPF.DependencyInjection;
|
||||||
using JNPF.DynamicApiController;
|
using JNPF.DynamicApiController;
|
||||||
|
using JNPF.FriendlyException;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using NPOI.SS.UserModel;
|
||||||
|
using NPOI.SS.Util;
|
||||||
|
using NPOI.XSSF.UserModel;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using Tnb.PerMgr.Entities;
|
using Tnb.PerMgr.Entities;
|
||||||
using Tnb.PerMgr.Entities.Dto;
|
using Tnb.PerMgr.Entities.Dto;
|
||||||
@@ -41,5 +46,6 @@ namespace Tnb.PerMgr
|
|||||||
}).SingleAsync();
|
}).SingleAsync();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
94
PerMgr/Tnb.PerMgr/PerProcessStandardsService.cs
Normal file
94
PerMgr/Tnb.PerMgr/PerProcessStandardsService.cs
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
using JNPF;
|
||||||
|
using JNPF.Common.Core.Manager;
|
||||||
|
using JNPF.Common.Enums;
|
||||||
|
using JNPF.Common.Helper;
|
||||||
|
using JNPF.Common.Security;
|
||||||
|
using JNPF.DependencyInjection;
|
||||||
|
using JNPF.DynamicApiController;
|
||||||
|
using JNPF.FriendlyException;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using NPOI.SS.UserModel;
|
||||||
|
using NPOI.SS.Util;
|
||||||
|
using NPOI.XSSF.UserModel;
|
||||||
|
using SqlSugar;
|
||||||
|
using Tnb.PerMgr.Entities;
|
||||||
|
using Tnb.PerMgr.Entities.Dto;
|
||||||
|
using Tnb.PerMgr.Interfaces;
|
||||||
|
|
||||||
|
namespace Tnb.PerMgr
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 工艺标准
|
||||||
|
/// </summary>
|
||||||
|
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
||||||
|
[Route("api/[area]/[controller]/[action]")]
|
||||||
|
public class PerProcessStandardsService : IPerProcessStandardsService, IDynamicApiController, ITransient
|
||||||
|
{
|
||||||
|
private readonly ISqlSugarRepository<PerProcessStandardsH> _repository;
|
||||||
|
private readonly IUserManager _userManager;
|
||||||
|
|
||||||
|
public PerProcessStandardsService(ISqlSugarRepository<PerProcessStandardsH> repository, IUserManager userManager)
|
||||||
|
{
|
||||||
|
_userManager = userManager;
|
||||||
|
_repository = repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
[AllowAnonymous]
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<IActionResult> ExportTemplate()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var db = _repository.AsSugarClient();
|
||||||
|
string[] perProcessParamTypes = await db.Queryable<PerProcessParamType>().OrderBy(x => x.ordinal).Select(x=>x.name).ToArrayAsync();
|
||||||
|
string[] perProcessParams = await db.Queryable<PerProcessParam>().OrderBy(x => x.ordinal).Select(x=>x.name).ToArrayAsync();
|
||||||
|
|
||||||
|
|
||||||
|
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||||
|
NPOI.SS.UserModel.ISheet sheet = workbook.CreateSheet("BOM详情");
|
||||||
|
|
||||||
|
IRow row1 = sheet.CreateRow(0);
|
||||||
|
string[] titles = new[] { "工艺参数类型", "工艺参数", "设定值" };
|
||||||
|
|
||||||
|
for (int i = 0; i < titles.Length; i++)
|
||||||
|
{
|
||||||
|
ICell cell1 = row1.CreateCell(i);
|
||||||
|
cell1.SetCellValue(titles[i]);
|
||||||
|
sheet.SetColumnWidth(i,15 * 256);
|
||||||
|
}
|
||||||
|
|
||||||
|
int rowIndex = 1;
|
||||||
|
|
||||||
|
// var column = sheet.GetColumn(0);
|
||||||
|
// 设置下拉项
|
||||||
|
var validationHelper = sheet.GetDataValidationHelper();
|
||||||
|
var constraint = validationHelper.CreateExplicitListConstraint(perProcessParamTypes);
|
||||||
|
var region = new CellRangeAddressList(1, 1000, 0, 0);
|
||||||
|
var validation = validationHelper.CreateValidation(constraint, region);
|
||||||
|
sheet.AddValidationData(validation);
|
||||||
|
|
||||||
|
var constraint2 = validationHelper.CreateExplicitListConstraint(perProcessParams);
|
||||||
|
var region2 = new CellRangeAddressList(1, 1000, 1, 1);
|
||||||
|
var validation2 = validationHelper.CreateValidation(constraint2, region2);
|
||||||
|
sheet.AddValidationData(validation2);
|
||||||
|
|
||||||
|
|
||||||
|
MemoryStream ms = new MemoryStream();
|
||||||
|
|
||||||
|
workbook.Write(ms);
|
||||||
|
MemoryStream ms2 = new MemoryStream(ms.ToArray());
|
||||||
|
ms2.Position = 0;
|
||||||
|
FileStreamResult fileStreamResult = new FileStreamResult(ms2, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") { FileDownloadName = "template.xlsx" };
|
||||||
|
return fileStreamResult;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e);
|
||||||
|
throw Oops.Bah("导出失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user