去除引用common.props

This commit is contained in:
2023-11-06 19:35:59 +08:00
parent 6a2154edd9
commit c6b8dfc861
810 changed files with 3910 additions and 6695 deletions

View File

@@ -1,18 +1,12 @@
using System.Data;
using JNPF;
using JNPF.Common.Configuration;
using JNPF.Common.Core.Manager;
using JNPF.Common.Core.Manager.Files;
using JNPF.Common.Enums;
using JNPF.Common.Helper;
using JNPF.Common.Models;
using JNPF.Common.Security;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
using JNPF.FriendlyException;
using JNPF.Systems.Common;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
@@ -20,7 +14,6 @@ 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
@@ -36,8 +29,8 @@ namespace Tnb.PerMgr
private readonly IUserManager _userManager;
private readonly FileManager _fileManager;
private readonly FileService _fileService;
public PerProcessStandardsService(ISqlSugarRepository<PerProcessStandardsH> repository,
public PerProcessStandardsService(ISqlSugarRepository<PerProcessStandardsH> repository,
FileService fileService,
FileManager fileManager,
IUserManager userManager)
@@ -47,7 +40,7 @@ namespace Tnb.PerMgr
_fileManager = fileManager;
_fileService = fileService;
}
[AllowAnonymous]
[HttpGet]
public async Task<IActionResult> ExportTemplate()
@@ -55,13 +48,13 @@ namespace Tnb.PerMgr
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();
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[] { "工艺参数类型", "工艺参数", "设定值" };
@@ -69,11 +62,11 @@ namespace Tnb.PerMgr
{
ICell cell1 = row1.CreateCell(i);
cell1.SetCellValue(titles[i]);
sheet.SetColumnWidth(i,15 * 256);
sheet.SetColumnWidth(i, 15 * 256);
}
// int rowIndex = 1;
// var column = sheet.GetColumn(0);
// 设置下拉项
var validationHelper = sheet.GetDataValidationHelper();
@@ -81,15 +74,15 @@ namespace Tnb.PerMgr
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;
@@ -101,11 +94,11 @@ namespace Tnb.PerMgr
Console.WriteLine(e);
throw Oops.Bah("导出失败");
}
}
[HttpPost]
public async Task<Dictionary<string,string>> Import([FromForm]string id, [FromForm]ChunkModel input)
public async Task<Dictionary<string, string>> Import([FromForm] string id, [FromForm] ChunkModel input)
{
int rowIndex = 1;
bool flag = false;
@@ -114,16 +107,16 @@ namespace Tnb.PerMgr
{
using (Stream stream = input.file.OpenReadStream())
{
// 2007版本
if (input.fileName.IndexOf(".xlsx") > 0)
workbook = new XSSFWorkbook(stream);
else if (input.fileName.IndexOf(".xls") > 0)
workbook = new HSSFWorkbook(stream);
ISheet? sheet = workbook?.GetSheetAt(0);
if(workbook==null || sheet==null)
if (workbook == null || sheet == null)
throw Oops.Bah("无导入数据");
if (sheet?.LastRowNum <= 1)
@@ -133,12 +126,12 @@ namespace Tnb.PerMgr
List<PerProcessParamType> perProcessParamTypes = await db.Queryable<PerProcessParamType>().ToListAsync();
List<PerProcessParam> perProcessParams = await db.Queryable<PerProcessParam>().ToListAsync();
int errorColumnIndex = 5;
ICellStyle style = workbook.CreateCellStyle();
IFont font = workbook.CreateFont();
IFont font = workbook.CreateFont();
font.Color = IndexedColors.Red.Index; // 将字体颜色设置为红色
style.SetFont(font);
List<PerProcessStandardsD> list = new List<PerProcessStandardsD>() { };
for (rowIndex = 1; rowIndex <= sheet?.LastRowNum; rowIndex++)
{
@@ -170,14 +163,14 @@ namespace Tnb.PerMgr
else
{
ICell errorCell = row.GetCell(errorColumnIndex) ?? row.CreateCell(errorColumnIndex);
errorCell.SetCellValue(errorCell.StringCellValue+",无该工艺参数");
errorCell.SetCellValue(errorCell.StringCellValue + ",无该工艺参数");
errorCell.CellStyle = style;
flag = true;
}
if (!TrySetNumberCellValue(cell2, ref item))
{
ICell errorCell = row.GetCell(errorColumnIndex) ?? row.CreateCell(errorColumnIndex);
errorCell.SetCellValue(errorCell.StringCellValue+",设定值不是数字");
errorCell.SetCellValue(errorCell.StringCellValue + ",设定值不是数字");
errorCell.CellStyle = style;
flag = true;
}
@@ -186,7 +179,7 @@ namespace Tnb.PerMgr
list.Add(item);
}
if (row.GetCell(errorColumnIndex) != null)
{
row.GetCell(errorColumnIndex).SetCellValue(row.GetCell(errorColumnIndex).StringCellValue.Substring(1));
@@ -199,18 +192,18 @@ namespace Tnb.PerMgr
.FirstAsync(x =>
x.process_param_id == item.process_param_id &&
x.process_param_type_id == item.process_param_type_id && x.process_standards_id == id);
if (oldData!=null)
if (oldData != null)
{
if (oldData.value != item.value)
{
PerProcessStandardsH perProcessStandardsH = await _repository.AsSugarClient().Queryable<PerProcessStandardsH>().SingleAsync(x => x.id == oldData.process_standards_id);
PerProcessParam processParam = await _repository.AsSugarClient().Queryable<PerProcessParam>().SingleAsync(x => x.id == oldData.process_param_id);
await _repository.AsSugarClient().Updateable<PerProcessStandardsD>()
.SetColumns(x=>x.value==item.value)
.Where(x=>x.id==oldData.id).ExecuteCommandAsync();
.SetColumns(x => x.value == item.value)
.Where(x => x.id == oldData.id).ExecuteCommandAsync();
PerProcessParamEditRecord record = new PerProcessParamEditRecord
{
process_param_id = item.process_param_id,
@@ -234,14 +227,14 @@ namespace Tnb.PerMgr
if (flag)
{
MemoryStream ms = new MemoryStream();
workbook?.Write(ms);
string fileName = $"工艺标准导入报错{DateTime.Now.Ticks}.xlsx";
using (MemoryStream ms2 = new MemoryStream(ms.ToArray()))
{
ms2.Position = 0;
await _fileManager.UploadFileByType(ms2, FileVariable.TemporaryFilePath, fileName);
}
return new Dictionary<string, string>()
{
@@ -258,21 +251,21 @@ namespace Tnb.PerMgr
["msg"] = "导入成功",
};
}
}
}
catch (Exception e)
{
{
Console.WriteLine(e.Message);
JNPF.Logging.Log.Error("工艺标准导入失败", e);
throw Oops.Bah("导入失败");
}
}
private bool TrySetNumberCellValue(ICell cell,ref PerProcessStandardsD item)
private bool TrySetNumberCellValue(ICell cell, ref PerProcessStandardsD item)
{
try
{