diff --git a/DOAN.Admin.WebApi/Program.cs b/DOAN.Admin.WebApi/Program.cs index 4b33ef3..f48cad0 100644 --- a/DOAN.Admin.WebApi/Program.cs +++ b/DOAN.Admin.WebApi/Program.cs @@ -12,6 +12,7 @@ using DOAN.Common.DynamicApiSimple.Extens; using DOAN.Infrastructure.WebExtensions; using DOAN.ServiceCore.Signalr; using DOAN.ServiceCore.SqlSugar; +using Microsoft.Extensions.FileProviders; var builder = WebApplication.CreateBuilder(args); // NLog: Setup NLog for Dependency injection @@ -134,6 +135,19 @@ app.Use((context, next) => return next(); }); //开启访问静态文件/wwwroot目录文件,要放在UseRouting前面 + +var fileProvider = new PhysicalFileProvider(InternalApp.Configuration.GetSection("Upload").GetSection("rootDirectory").Get()); +var requestPath = "/device"; +app.UseStaticFiles(new StaticFileOptions +{ + FileProvider = fileProvider, + RequestPath = requestPath +}); +app.UseStaticFiles(new StaticFileOptions +{ + FileProvider = fileProvider +}); + app.UseStaticFiles(); //开启路由访问 app.UseRouting(); @@ -165,5 +179,14 @@ app.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); + + app.MapControllers(); + + +app.UseDirectoryBrowser(new DirectoryBrowserOptions +{ + FileProvider = fileProvider, + RequestPath = requestPath +}); app.Run(); \ No newline at end of file diff --git a/DOAN.Admin.WebApi/appsettings.Development.json b/DOAN.Admin.WebApi/appsettings.Development.json index 7ed0eff..aa6b563 100644 --- a/DOAN.Admin.WebApi/appsettings.Development.json +++ b/DOAN.Admin.WebApi/appsettings.Development.json @@ -3,7 +3,7 @@ { // 远程测试服务器 "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", + // "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 @@ -19,6 +19,15 @@ "DbName": "bzfm_mes" //代码生成默认连接数据库,Oracle库是实例的名称 }, "ShowDbLog": true, //是否打印db日志 - "urls": "http://localhost:8888", //项目启动url,如果改动端口前端对应devServer也需要进行修改 - "corsUrls": [ "http://localhost:8887", "http://localhost:8886", "http://localhost:9090", "http://localhost:8080" ] //跨域地址(前端启动项目,前后端分离单独部署需要设置),多个用","隔开 + "urls": "http://0.0.0.0:8888", //项目启动url,如果改动端口前端对应devServer也需要进行修改 + "corsUrls": [ "http://localhost:8887", "http://localhost:8886", "http://localhost:9090", "http://localhost:8080" ], //跨域地址(前端启动项目,前后端分离单独部署需要设置),多个用","隔开 + "Upload": { + "rootDirectory": "D:/MES/file", + "uploadUrl": "http://172.18.32.1:8888", //本地存储资源访问路径 + "localSavePath": "", //本地上传默认文件存储目录 wwwroot + "maxSize": 30, //上传文件大小限制 15M + "notAllowedExt": [ ".bat", ".exe", ".jar", ".js" ], + "requestLimitSize": 100 //请求body大小限制 + } + } \ No newline at end of file diff --git a/DOAN.Admin.WebApi/appsettings.json b/DOAN.Admin.WebApi/appsettings.json index 0e66047..17e0c19 100644 --- a/DOAN.Admin.WebApi/appsettings.json +++ b/DOAN.Admin.WebApi/appsettings.json @@ -24,13 +24,7 @@ "SingleLogin": false, //是否允许多设备/浏览器登录 "workId": 1, //雪花id唯一数字 "sqlExecutionTime": 5, //Sql执行时间超过多少秒记录日志并警报 - "Upload": { - "uploadUrl": "http://127.0.0.1:8888", //本地存储资源访问路径 - "localSavePath": "", //本地上传默认文件存储目录 wwwroot - "maxSize": 30, //上传文件大小限制 15M - "notAllowedExt": [ ".bat", ".exe", ".jar", ".js" ], - "requestLimitSize": 100 //请求body大小限制 - }, + //阿里云存储配置 "ALIYUN_OSS": { "REGIONID": "", //eg:cn-hangzhou diff --git a/DOAN.Model/MES/Base/Dto/BaseDeviceDto.cs b/DOAN.Model/MES/Base/Dto/BaseDeviceDto.cs index d887969..7c40289 100644 --- a/DOAN.Model/MES/Base/Dto/BaseDeviceDto.cs +++ b/DOAN.Model/MES/Base/Dto/BaseDeviceDto.cs @@ -27,7 +27,7 @@ namespace DOAN.Model.MES.base_.Dto /// public class BaseDeviceDto { - [Required(ErrorMessage = "主键不能为空")] + // [Required(ErrorMessage = "主键不能为空")] public int Id { get; set; } public int? FkWorkStation { get; set; } diff --git a/DOAN.Model/MES/Device/Dto/DeviceFormConfigDto.cs b/DOAN.Model/MES/Device/Dto/DeviceFormConfigDto.cs index 3f4bc93..89be157 100644 --- a/DOAN.Model/MES/Device/Dto/DeviceFormConfigDto.cs +++ b/DOAN.Model/MES/Device/Dto/DeviceFormConfigDto.cs @@ -16,7 +16,7 @@ namespace DOAN.Model.MES.dev.Dto /// public class DeviceFormConfigDto { - [Required(ErrorMessage = "id 雪花不能为空")] + //[Required(ErrorMessage = "id 雪花不能为空")] public string Id { get; set; } public int FkDeviceInspectId { get; set; } diff --git a/DOAN.Model/MES/Device/Dto/DeviceInspectDto.cs b/DOAN.Model/MES/Device/Dto/DeviceInspectDto.cs index 4025e9b..e692d4a 100644 --- a/DOAN.Model/MES/Device/Dto/DeviceInspectDto.cs +++ b/DOAN.Model/MES/Device/Dto/DeviceInspectDto.cs @@ -46,7 +46,7 @@ namespace DOAN.Model.MES.dev.Dto /// public class DeviceInspectDto { - [Required(ErrorMessage = "id不能为空")] + // [Required(ErrorMessage = "id不能为空")] public int Id { get; set; } public string Image { get; set; } diff --git a/DOAN.Model/MES/Device/Dto/DeviceMaintenanceRecordDto.cs b/DOAN.Model/MES/Device/Dto/DeviceMaintenanceRecordDto.cs index 5f34f0a..b645ad8 100644 --- a/DOAN.Model/MES/Device/Dto/DeviceMaintenanceRecordDto.cs +++ b/DOAN.Model/MES/Device/Dto/DeviceMaintenanceRecordDto.cs @@ -14,7 +14,7 @@ namespace DOAN.Model.MES.dev.Dto /// public class DeviceMaintenanceRecordDto { - [Required(ErrorMessage = "id不能为空")] + // [Required(ErrorMessage = "id不能为空")] public string Id { get; set; } public string FkRepairId { get; set; } diff --git a/DOAN.Model/MES/Device/Dto/DevicePointInspectionPlanDto.cs b/DOAN.Model/MES/Device/Dto/DevicePointInspectionPlanDto.cs index 943d5dd..d1dd273 100644 --- a/DOAN.Model/MES/Device/Dto/DevicePointInspectionPlanDto.cs +++ b/DOAN.Model/MES/Device/Dto/DevicePointInspectionPlanDto.cs @@ -19,7 +19,7 @@ namespace DOAN.Model.MES.dev.Dto /// public class DevicePointInspectionPlanDto { - [Required(ErrorMessage = "id不能为空")] + // [Required(ErrorMessage = "id不能为空")] public string Id { get; set; } public string Name { get; set; } diff --git a/DOAN.Model/MES/Device/Dto/DeviceRepairDto.cs b/DOAN.Model/MES/Device/Dto/DeviceRepairDto.cs index 8f04500..7e890b3 100644 --- a/DOAN.Model/MES/Device/Dto/DeviceRepairDto.cs +++ b/DOAN.Model/MES/Device/Dto/DeviceRepairDto.cs @@ -41,7 +41,7 @@ namespace DOAN.Model.MES.dev.Dto /// public class DeviceRepairDto { - [Required(ErrorMessage = "雪花id不能为空")] + // [Required(ErrorMessage = "雪花id不能为空")] public string Id { get; set; } public string RepairOrder { get; set; } diff --git a/DOAN.Model/MES/Device/Dto/DeviceRouteInspectionPlanDto.cs b/DOAN.Model/MES/Device/Dto/DeviceRouteInspectionPlanDto.cs index d09f75d..f2e0d86 100644 --- a/DOAN.Model/MES/Device/Dto/DeviceRouteInspectionPlanDto.cs +++ b/DOAN.Model/MES/Device/Dto/DeviceRouteInspectionPlanDto.cs @@ -20,7 +20,7 @@ namespace DOAN.Model.MES.dev.Dto /// public class DeviceRouteInspectionPlanDto { - [Required(ErrorMessage = "id不能为空")] + // [Required(ErrorMessage = "id不能为空")] public string Id { get; set; } public string Name { get; set; } diff --git a/Infrastructure/Helper/PrintHelper.cs b/Infrastructure/Helper/PrintHelper.cs index e649285..9d98ff1 100644 --- a/Infrastructure/Helper/PrintHelper.cs +++ b/Infrastructure/Helper/PrintHelper.cs @@ -48,5 +48,41 @@ public class PrintHelper } + /// + /// 打印二维码 + /// + /// + /// + /// + /// + public static byte[] CreateQcCode(string message, int width, int height) + { + if (string.IsNullOrWhiteSpace(message)) + { + return null; + } + var w = new ZXing.OneD.Code128Writer(); + BitMatrix b = w.encode(message, BarcodeFormat.QR_CODE, width, height); + var zzb = new ZXing.ZKWeb.BarcodeWriter(); + zzb.Options = new EncodingOptions() + { + Margin = 0, + PureBarcode = false + }; + + Bitmap b2 = zzb.Write(b); + + + using (var ms = new System.IO.MemoryStream()) + { + b2.Save(ms, ImageFormat.Png); + var bytes = ms.ToArray(); + + return bytes; + } + + + } + } \ No newline at end of file