diff --git a/DOAN.Admin.WebApi/Controllers/CommonController.cs b/DOAN.Admin.WebApi/Controllers/CommonController.cs
index 443fce3..e1ab358 100644
--- a/DOAN.Admin.WebApi/Controllers/CommonController.cs
+++ b/DOAN.Admin.WebApi/Controllers/CommonController.cs
@@ -92,17 +92,16 @@ namespace DOAN.Admin.WebApi.Controllers
/// 存储文件
///
/// 自定义文件名
- ///
/// 上传类型1、保存到本地 2、保存到阿里云
///
[HttpPost()]
[Verify]
[ActionPermissionFilter(Permission = "common")]
- public async Task UploadFile([FromForm] UploadDto uploadDto, IFormFile file, StoreType storeType = StoreType.LOCAL)
+ public async Task UploadFile([FromForm] UploadDto2 uploadDto, StoreType storeType = StoreType.LOCAL)
{
- if (file == null) throw new CustomException(ResultCode.PARAM_ERROR, "上传文件不能为空");
- SysFile sysfile = new();
- IFormFile formFile = file;
+ IFormFile formFile = uploadDto.File;
+ if (formFile == null) throw new CustomException(ResultCode.PARAM_ERROR, "上传文件不能为空");
+ SysFile file = new();
string fileExt = Path.GetExtension(formFile.FileName);//文件后缀
double fileSize = Math.Round(formFile.Length / 1024.0, 2);//文件大小KB
@@ -121,12 +120,27 @@ namespace DOAN.Admin.WebApi.Controllers
switch (storeType)
{
case StoreType.LOCAL:
- string savePath = Path.Combine(WebHostEnvironment.WebRootPath);
+ string savePath = null;
+ if (string.IsNullOrEmpty(OptionsSetting.Upload.rootDirectory))
+ {
+ savePath = Path.Combine(WebHostEnvironment.WebRootPath);
+
+ }
+ else
+ {
+ savePath = Path.Combine(OptionsSetting.Upload.rootDirectory);
+ if (!Directory.Exists(savePath))
+ {
+ Directory.CreateDirectory(savePath);
+ }
+ }
+
if (uploadDto.FileDir.IsEmpty())
{
uploadDto.FileDir = OptionsSetting.Upload.LocalSavePath;
}
- sysfile = await SysFileService.SaveFileToLocal(savePath, uploadDto.FileName, uploadDto.FileDir, HttpContext.GetName(), formFile);
+ //savePath 根目录 uploadDto.FileName uploadDto.FileName
+ file = await SysFileService.SaveFileToLocal(savePath, uploadDto.FileName, uploadDto.FileName, HttpContext.GetName(), formFile, uploadDto.filePath);
break;
case StoreType.REMOTE:
break;
@@ -140,14 +154,14 @@ namespace DOAN.Admin.WebApi.Controllers
{
return ToResponse(ResultCode.CUSTOM_ERROR, "上传文件过大,不能超过 " + AlimaxContentLength + " MB");
}
- sysfile = new(formFile.FileName, uploadDto.FileName, fileExt, fileSize + "kb", uploadDto.FileDir, HttpContext.GetName())
+ file = new(formFile.FileName, uploadDto.FileName, fileExt, fileSize + "kb", uploadDto.FileDir, HttpContext.GetName())
{
StoreType = (int)StoreType.ALIYUN,
FileType = formFile.ContentType
};
- sysfile = await SysFileService.SaveFileToAliyun(sysfile, formFile);
+ file = await SysFileService.SaveFileToAliyun(file, formFile);
- if (sysfile.Id <= 0) { return ToResponse(ApiResult.Error("阿里云连接失败")); }
+ if (file.Id <= 0) { return ToResponse(ApiResult.Error("阿里云连接失败")); }
break;
case StoreType.TENCENT:
break;
@@ -158,12 +172,31 @@ namespace DOAN.Admin.WebApi.Controllers
}
return SUCCESS(new
{
- url = sysfile.AccessUrl,
- fileName = sysfile.FileName,
- fileId = sysfile.Id.ToString()
+ url = file.AccessUrl,
+ fileName = file.FileName,
+ fileId = file.Id.ToString()
});
}
-
+ public class UploadDto2
+ {
+ ///
+ /// 自定文件名
+ ///
+ public string? FileName { get; set; }
+ ///
+ /// 存储目录
+ ///
+ public string? FileDir { get; set; }
+ ///
+ /// 文件名生成类型 1 原文件名 2 自定义 3 自动生成
+ ///
+ public int FileNameType { get; set; }
+ ///
+ /// 存储目录 比FileDir 优先
+ ///
+ public string filePath { get; set; }
+ public IFormFile? File { get; set; }
+ }
#endregion
///
diff --git a/DOAN.Admin.WebApi/Controllers/Mobile/ReportFlowController.cs b/DOAN.Admin.WebApi/Controllers/Mobile/ReportFlowController.cs
index 054d90a..f47a5f5 100644
--- a/DOAN.Admin.WebApi/Controllers/Mobile/ReportFlowController.cs
+++ b/DOAN.Admin.WebApi/Controllers/Mobile/ReportFlowController.cs
@@ -56,14 +56,14 @@ public class ReportFlowController : BaseController
}
//TODO 领料工序
[HttpGet("feed_process_reportwork")]
- public IActionResult FeedProcessReportwork(string workorder, int processId, int finish_num,string stove_code,string feed_order)
+ public IActionResult FeedProcessReportwork(string workorder, int processId, int finish_num,string stove_code,string feed_order,string process_operator)
{
if (string.IsNullOrEmpty(workorder))
{
throw new CustomException("workorder or process is null");
}
- return SUCCESS(_reportFlowService.FeedProcessReportwork(workorder, processId, finish_num, stove_code, feed_order, HttpContext.GetNickName()));
+ return SUCCESS(_reportFlowService.FeedProcessReportwork(workorder, processId, finish_num, stove_code, feed_order, process_operator));
}
//TODO 工序报工
@@ -77,26 +77,26 @@ public class ReportFlowController : BaseController
///
///
[HttpGet("process_reportwork")]
- public IActionResult ProcessReportWork(string workorder, int processId, int finish_num,int bad_num)
+ public IActionResult ProcessReportWork(string workorder, int processId, int finish_num,int bad_num,string process_operator)
{
if (string.IsNullOrEmpty(workorder))
{
throw new CustomException("workorder or process is null");
}
- return SUCCESS(_reportFlowService.ProcessReportWork(workorder, processId, finish_num,bad_num,HttpContext.GetNickName()));
+ return SUCCESS(_reportFlowService.ProcessReportWork(workorder, processId, finish_num,bad_num, process_operator));
}
//TODO 出货工序
[HttpGet("shipment_process_reportwork")]
- public IActionResult ShipmentProcessReportwork(string workorder, int processId, int finish_num, int bad_num, string customer_order)
+ public IActionResult ShipmentProcessReportwork(string workorder, int processId, int finish_num, int bad_num, string customer_order, string process_operator)
{
if (string.IsNullOrEmpty(workorder))
{
throw new CustomException("workorder or process is null");
}
- return SUCCESS(_reportFlowService.ShipmentProcessReportwork(workorder, processId, finish_num, bad_num, customer_order, HttpContext.GetNickName()));
+ return SUCCESS(_reportFlowService.ShipmentProcessReportwork(workorder, processId, finish_num, bad_num, customer_order, process_operator));
}
//TODO 获取工单下的报工列表
diff --git a/DOAN.Admin.WebApi/HttpAPI.http b/DOAN.Admin.WebApi/HttpAPI.http
new file mode 100644
index 0000000..575ce3b
--- /dev/null
+++ b/DOAN.Admin.WebApi/HttpAPI.http
@@ -0,0 +1,7 @@
+### GET request to example server
+GET https://examples.http-client.intellij.net/get
+ ?generated-in=JetBrains Rider
+
+### 工单打印接口
+GET http://localhost:8888/mes/productManagement/ProWorkorder/print?workorderArray=20241210_3A_1_001
+##
\ No newline at end of file
diff --git a/DOAN.Admin.WebApi/appsettings.Development.json b/DOAN.Admin.WebApi/appsettings.Development.json
index cbbc6bf..7ed0eff 100644
--- a/DOAN.Admin.WebApi/appsettings.Development.json
+++ b/DOAN.Admin.WebApi/appsettings.Development.json
@@ -2,7 +2,8 @@
"dbConfigs": [
{
// 远程测试服务器
- "Conn": "Data Source=192.168.0.58;User ID=root;Password=123456;Initial Catalog=bzfm_mes;Port=3306",
+ "Conn": "Data Source=139.224.232.211;User ID=root;Password=doantech123;Initial Catalog=bzfm_mes;Port=3308",
+ // "Conn": "Data Source=192.168.0.58;User ID=root;Password=123456;Initial Catalog=bzfm_mes;Port=3306",
"DbType": 0, //数据库类型 MySql = 0, SqlServer = 1, Oracle = 3,PgSql = 4
"ConfigId": "0", //多租户唯一标识
"IsAutoCloseConnection": true
diff --git a/DOAN.Admin.WebApi/appsettings.Production.json b/DOAN.Admin.WebApi/appsettings.Production.json
index 00ee5c5..db12d60 100644
--- a/DOAN.Admin.WebApi/appsettings.Production.json
+++ b/DOAN.Admin.WebApi/appsettings.Production.json
@@ -19,5 +19,13 @@
},
"ShowDbLog": false, //是否打印db日志
"urls": "http://0.0.0.0:8888", //项目启动url,如果改动端口前端对应devServer也需要进行修改
- "corsUrls": [ "http://localhost:8887", "http://localhost:8886", "http://localhost:9090", "http://localhost:8080" ] //跨域地址(前端启动项目,前后端分离单独部署需要设置),多个用","隔开
+ "corsUrls": [ "http://localhost:8887", "http://localhost:8886", "http://localhost:9090", "http://localhost:8080" ], //跨域地址(前端启动项目,前后端分离单独部署需要设置),多个用","隔开
+ "Upload": {
+ "rootDirectory": "D:/MES/file",
+ "uploadUrl": "http://127.0.0.1:7000", //本地存储资源访问路径
+ "localSavePath": "", //本地上传默认文件存储目录 wwwroot+localSavePath
+ "maxSize": 15, //上传文件大小限制 15M
+ "notAllowedExt": [ ".bat", ".exe", ".jar", ".js" ]
+ }
+
}
\ No newline at end of file
diff --git a/DOAN.Model/System/Model/Dto/UploadDto.cs b/DOAN.Model/System/Model/Dto/UploadDto.cs
index a4e210d..f201bfc 100644
--- a/DOAN.Model/System/Model/Dto/UploadDto.cs
+++ b/DOAN.Model/System/Model/Dto/UploadDto.cs
@@ -1,4 +1,5 @@
-namespace DOAN.Model.Dto
+
+namespace DOAN.Model.Dto
{
public class UploadDto
{
@@ -14,5 +15,10 @@
/// 文件名生成类型 1 原文件名 2 自定义 3 自动生成
///
public int FileNameType { get; set; }
+ ///
+ /// 存储目录 比FileDir 优先
+ ///
+ public string filePath { get; set; }
+
}
}
diff --git a/DOAN.Service/MES/Product/ProWorkorderService.cs b/DOAN.Service/MES/Product/ProWorkorderService.cs
index 5cc56b4..c92ad14 100644
--- a/DOAN.Service/MES/Product/ProWorkorderService.cs
+++ b/DOAN.Service/MES/Product/ProWorkorderService.cs
@@ -30,6 +30,7 @@ using DOAN.Model.MES.base_.Dto;
using Infrastructure.Converter;
using QuestPDF;
using QuestPDF.Fluent;
+using QuestPDF.Helpers;
using QuestPDF.Infrastructure;
@@ -679,8 +680,8 @@ namespace DOAN.Service.MES.product
int index = (row - 3);
string nickCode = ProductCodeList.Where(it => it.DictLabel == workorder.productionCode)
.Select(it => it.DictValue).FirstOrDefault();
- workorder.Workorder = dateValue.ToString("yyyyMMdd") + "_" + workorder.RouteCode +
- workorder.GroupCode + "_" + nickCode + "_" + index.ToString("000");
+ workorder.Workorder = dateValue.ToString("yyyyMMdd") + "_" +workorder.GroupCode+ workorder.RouteCode +
+ "_" + nickCode + "_" + index.ToString("000");
workorder.Sort = index * 10;
@@ -997,8 +998,8 @@ namespace DOAN.Service.MES.product
string nickCode = ProductCodeList.Where(it => it.DictLabel == workorder.productionCode)
.Select(it => it.DictValue).FirstOrDefault();
- workorder.Workorder = dateValue.ToString("yyyyMMdd") + "_" + workorder.RouteCode +
- workorder.GroupCode + "_" + nickCode + "_" + index.ToString("000");
+ workorder.Workorder = dateValue.ToString("yyyyMMdd") + "_" + workorder.GroupCode+ workorder.RouteCode +
+ "_" + nickCode + "_" + index.ToString("000");
workorder.Sort = index * 10 + Convert.ToInt16(MaxWorkorder.Sort);
@@ -1299,7 +1300,12 @@ namespace DOAN.Service.MES.product
}
-
+
+ ///
+ /// https://www.questpdf.com/
+ ///
+ ///
+ ///
public async Task<(string, Stream)> ExportPDFByQuestPDFDemo(string[] workorderArray)
{
@@ -1315,38 +1321,51 @@ namespace DOAN.Service.MES.product
Settings.CheckIfAllTextGlyphsAreAvailable = false;
var document = QuestPDF.Fluent.Document.Create(container =>
{
+ int PageWidth = 40 * 10;
+ int PageHeight = 30 * 10;
for (int i = 0; i < dataList.Count(); i++)
{
- byte[] imageBytes= PrintHelper.CreateBarCode(dataList[i].Workorder, 30, 30);
- container.Page(page =>
+ byte[] imageBytes = PrintHelper.CreateBarCode(dataList[i].Workorder, PageWidth * 3, PageHeight);
+ container.Page(page =>
{
- page.Margin(20);
+ // 设置页面大小为A4,默认有页边距
+ //page.Size(new PageSize(40*10,30*10)); // 移除默认页边距或设置自定义边距
+
+ page.Size(PageWidth, PageHeight);
+ page.DefaultTextStyle(TextStyle.Default.FontSize(16*2-5));
+ //page.DefaultTextStyle(TextStyle.Default.FontSize(1));
page.Content().Column(column =>
{
-
column.Item().Table(table =>
{
- // Define columns
+ // 动态计算列宽,减去必要的边距
+ float columnWidth = (PageWidth) / 8;
+
table.ColumnsDefinition(columns =>
{
- columns.RelativeColumn(); // Column 1
- columns.RelativeColumn(); // Column 2
- columns.RelativeColumn();
- columns.RelativeColumn();
- columns.RelativeColumn();
- columns.RelativeColumn();
- columns.RelativeColumn();
- columns.RelativeColumn();
+ for (int j = 0; j < 8; j++)
+ columns.ConstantColumn(columnWidth);
});
- table.Cell().Row(1).ColumnSpan(8).Image(imageBytes);
-
- table.Cell().Row(2).Column(2).Text("编号");
- table.Cell().Row(2).Column(6).Text(dataList[i].Workorder);
- table.Cell().Row(3).Column(2).Text("炉号");
- table.Cell().Row(3).Column(6).Text(dataList[i].StoveCode);
- table.Cell().Row(4).Column(2).Text("数量");
- table.Cell().Row(4).Column(6).Text(dataList[i].PlanNum);
-
+
+ // 创建一个单元格跨越所有列,用于放置图片
+ table.Cell().ColumnSpan(8).Image(imageBytes);
+ table.Cell().ColumnSpan(8).MinHeight(PageHeight / 7/4);
+
+ // 剩余内容...
+ // 注意:确保剩余内容的高度不超过剩余的页面空间
+ // 这里只是一个简单的例子,实际应用中你可能需要更复杂的逻辑来计算剩余可用空间
+
+ table.Cell().ColumnSpan(2).Border(1).MinHeight(PageHeight/7).AlignLeft().Padding(1).Text("编号");
+ table.Cell().ColumnSpan(6).Border(1).MinHeight(PageHeight/7).AlignLeft().Padding(1).Text(dataList[i].Workorder);
+ table.Cell().ColumnSpan(2).Border(1).MinHeight(PageHeight/7).AlignLeft().Padding(1).Text("炉号");
+ table.Cell().ColumnSpan(6).Border(1).MinHeight(PageHeight/7).AlignLeft().Padding(1).Text(dataList[i].StoveCode);
+ table.Cell().ColumnSpan(2).Border(1).MinHeight(PageHeight/7).AlignLeft().Padding(1).Text("数量");
+ table.Cell().ColumnSpan(6).Border(1).MinHeight(PageHeight/7).AlignLeft().Padding(1).Text(dataList[i].PlanNum);
+ for (int j = 0; j< 8; j++)
+ {
+ table.Cell().Border(1).MinHeight(PageHeight/7).AlignCenter().Text($"[{j+1}]");
+ }
+
});
});
});
diff --git a/DOAN.Service/Mobile/ReportFlowService.cs b/DOAN.Service/Mobile/ReportFlowService.cs
index 23c747a..d3074d3 100644
--- a/DOAN.Service/Mobile/ReportFlowService.cs
+++ b/DOAN.Service/Mobile/ReportFlowService.cs
@@ -2,6 +2,7 @@ using DOAN.Model.MES.base_;
using DOAN.Model.MES.product;
using DOAN.Model.Mobile.ReportFlow.Dto;
using DOAN.Model.Public;
+using DOAN.Model.System;
using DOAN.Service.Mobile.IService;
using DOAN.Service.Public.IPublicService;
using Infrastructure.Attribute;
@@ -41,6 +42,9 @@ public class ReportFlowService : BaseService, IReportFlowServic
{
int result = 0;
bool Exist = Context.Queryable().Where(it => it.Workorder == workorder && it.ProcessId == processId).Any();
+
+ string NickName= Context.Queryable().Where(it=>it.UserName==Worker).Select(it=>it.NickName).First();
+ Worker = string.IsNullOrEmpty(NickName) ? Worker : NickName;
if (Exist)
{
result = Context.Updateable().Where(it => it.Workorder == workorder && it.ProcessId == processId)
@@ -81,6 +85,8 @@ public class ReportFlowService : BaseService, IReportFlowServic
{
int result = 0;
bool Exist = Context.Queryable().Where(it => it.Workorder == workorder && it.ProcessId == process).Any();
+ string NickName = Context.Queryable().Where(it => it.UserName == Worker).Select(it => it.NickName).First();
+ Worker = string.IsNullOrEmpty(NickName) ? Worker : NickName;
if (Exist)
{
result = Context.Updateable().Where(it => it.Workorder == workorder && it.ProcessId == process)
@@ -125,6 +131,8 @@ public class ReportFlowService : BaseService, IReportFlowServic
{
int result = 0;
bool Exist = Context.Queryable().Where(it => it.Workorder == workorder && it.ProcessId == processId).Any();
+ string NickName = Context.Queryable().Where(it => it.UserName == Worker).Select(it => it.NickName).First();
+ Worker = string.IsNullOrEmpty(NickName) ? Worker : NickName;
if (Exist)
{
result = Context.Updateable()
diff --git a/DOAN.ServiceCore/Services/IService/ISysFileService.cs b/DOAN.ServiceCore/Services/IService/ISysFileService.cs
index 8915c43..56f8f53 100644
--- a/DOAN.ServiceCore/Services/IService/ISysFileService.cs
+++ b/DOAN.ServiceCore/Services/IService/ISysFileService.cs
@@ -17,7 +17,16 @@ namespace DOAN.ServiceCore.Services
///
/// 文件对象
Task SaveFileToLocal(string rootPath, string fileName, string fileDir, string userName, IFormFile formFile);
-
+ ///
+ /// 上传文件
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// 文件对象
+ Task SaveFileToLocal(string rootPath, string fileName, string fileDir, string userName, IFormFile formFile, string filePath);
Task SaveFileToAliyun(SysFile file, IFormFile formFile);
///
/// 按时间来创建文件夹
diff --git a/DOAN.ServiceCore/Services/SysFileService.cs b/DOAN.ServiceCore/Services/SysFileService.cs
index 1fdf76b..50530c6 100644
--- a/DOAN.ServiceCore/Services/SysFileService.cs
+++ b/DOAN.ServiceCore/Services/SysFileService.cs
@@ -69,6 +69,50 @@ namespace DOAN.ServiceCore.Services
return file;
}
+
+ ///
+ /// 存储本地
+ ///
+ /// 存储文件夹
+ /// 存储根目录
+ /// 自定文件名
+ /// 上传的文件流
+ ///
+ /// 文件路径
+ ///
+ public async Task SaveFileToLocal(string rootPath, string fileName, string fileDir, string userName, IFormFile formFile, string filePath)
+ {
+ string fileExt = Path.GetExtension(formFile.FileName);
+ fileName = (fileName.IsEmpty() ? HashFileName() : fileName) + fileExt;
+ if (string.IsNullOrEmpty(filePath))
+ {
+ filePath = GetdirPath(fileDir);
+ }
+
+ string finalFilePath = Path.Combine(rootPath, filePath, fileName);
+ double fileSize = Math.Round(formFile.Length / 1024.0, 2);
+
+ if (!Directory.Exists(Path.GetDirectoryName(finalFilePath)))
+ {
+ Directory.CreateDirectory(Path.GetDirectoryName(finalFilePath));
+ }
+
+ using (var stream = new FileStream(finalFilePath, FileMode.Create))
+ {
+ await formFile.CopyToAsync(stream);
+ }
+ string uploadUrl = OptionsSetting.Upload.UploadUrl;
+ string accessPath = string.Concat(uploadUrl, "/", filePath.Replace("\\", "/"), "/", fileName);
+ SysFile file = new(formFile.FileName, fileName, fileExt, fileSize + "kb", filePath, userName)
+ {
+ StoreType = (int)StoreType.LOCAL,
+ FileType = formFile.ContentType,
+ FileUrl = finalFilePath.Replace("\\", "/"),
+ AccessUrl = accessPath
+ };
+ file.Id = await InsertFile(file);
+ return file;
+ }
///
/// 上传文件到阿里云
///
diff --git a/Infrastructure/Helper/PrintHelper.cs b/Infrastructure/Helper/PrintHelper.cs
index 75c3c6f..e649285 100644
--- a/Infrastructure/Helper/PrintHelper.cs
+++ b/Infrastructure/Helper/PrintHelper.cs
@@ -30,7 +30,7 @@ public class PrintHelper
var zzb = new ZXing.ZKWeb.BarcodeWriter();
zzb.Options = new EncodingOptions()
{
- Margin = 3,
+ Margin = 0,
PureBarcode = false
};
diff --git a/Infrastructure/Model/OptionsSetting.cs b/Infrastructure/Model/OptionsSetting.cs
index 4f9f552..9061138 100644
--- a/Infrastructure/Model/OptionsSetting.cs
+++ b/Infrastructure/Model/OptionsSetting.cs
@@ -68,6 +68,7 @@ namespace Infrastructure.Model
///
public class Upload
{
+ public string rootDirectory { get; set; }
public string UploadUrl { get; set; }
public string LocalSavePath { get; set; }
public int MaxSize { get; set; }