This commit is contained in:
SMR
2024-10-21 14:50:20 +08:00
parent d4fd12fd96
commit dec6b8582f
21 changed files with 409 additions and 16 deletions

7
ClassLibrary1/Class1.cs Normal file
View File

@@ -0,0 +1,7 @@
namespace ClassLibrary1
{
public class Class1
{
}
}

View File

@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -53,7 +53,7 @@ namespace DOAN.Admin.WebApi.Controllers
{
var hello = _localizer["hello"].Value;
return Ok($"{hello}看到这里页面说明你已经成功启动了本项目:)\n\n" +
"如果觉得项目有用,打赏作者喝杯咖啡作为奖励\n☛☛http://www.izhaorui.cn/vip\n");
"苏州道安自动化有限公司");
}
/// <summary>

View File

@@ -5,7 +5,7 @@ using DOAN.Service.PBL.IService;
using DOAN.Admin.WebApi.Filters;
//创建时间2024-09-23
namespace DOAN.Admin.WebApi.Controllers.Business
namespace DOAN.Admin.WebApi.Controllers.PBL
{
/// <summary>
/// 物料清单

View File

@@ -0,0 +1,53 @@
using Microsoft.AspNetCore.Mvc;
using DOAN.Model.PBL.Dto;
using DOAN.Model.PBL;
using DOAN.Service.PBL.IService;
using DOAN.Admin.WebApi.Filters;
//创建时间2024-09-23
namespace DOAN.Admin.WebApi.Controllers.PBL
{
/// <summary>
/// 与MES交互
/// </summary>
[AllowAnonymous]
[Route("PBL/mes_interation")]
public class MESInteractionController : BaseController
{
private readonly IMESInteractionServcie mesInteraction;
public MESInteractionController(IMESInteractionServcie mesInteraction)
{
this.mesInteraction = mesInteraction;
}
//TODO 接受工单 亮灯
[HttpPost("mes_light_up")]
public IActionResult MESLightUp([FromBody] LightUpDto light)
{
var response= mesInteraction.MESLightUp(light);
return SUCCESS(response);
}
//TODO 扫码灭灯
[HttpGet("mes_light_down")]
public IActionResult MESLightDown(string scan_code)
{
if(string.IsNullOrEmpty(scan_code))
{
throw new CustomException("扫描内容为空");
}
var response = mesInteraction.MESLightDown(scan_code);
return SUCCESS(response);
}
}
}

View File

@@ -5,7 +5,7 @@ using DOAN.Service.PBL.IService;
using DOAN.Admin.WebApi.Filters;
//创建时间2024-09-23
namespace DOAN.Admin.WebApi.Controllers.Business
namespace DOAN.Admin.WebApi.Controllers.PBL
{
/// <summary>
/// 料架表

View File

@@ -84,6 +84,9 @@ builder.Services.AddSignalR()
builder.Services.AddSwaggerConfig();
// 显示logo
builder.Services.AddLogo();
//激活 HslCommunication
builder.Services.AddHslCommunication();
// 添加本地化服务
builder.Services.AddLocalization(options => options.ResourcesPath = "");

View File

@@ -14,8 +14,9 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<WebPublishMethod>FileSystem</WebPublishMethod>
<_TargetId>Folder</_TargetId>
<SiteUrlToLaunchAfterPublish />
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ProjectGuid>e5497bb4-b0c1-4794-9fae-163f626ec399</ProjectGuid>
<SelfContained>false</SelfContained>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>
</Project>

View File

@@ -10,7 +10,7 @@
"dbConfigs": [
{
"Conn": "Data Source=192.168.0.58;User ID=root;Password=123456;Initial Catalog=pbl_huaxiang;Charset=utf8mb4",
"Conn": "Data Source=127.0.0.1;User ID=root;Password=123456;Initial Catalog=pbl_huaxiang;Charset=utf8mb4",
"DbType": 0, //数据库类型 MySql = 0, SqlServer = 1, Oracle = 3PgSql = 4
"ConfigId": "0", //多租户唯一标识
"IsAutoCloseConnection": true
@@ -20,12 +20,12 @@
//代码生成数据库配置
"CodeGenDbConfig": {
//代码生成连接字符串,注意{dbName}为固定格式,不要填写数据库名
"Conn": "Data Source=192.168.0.58;User ID=root;Password=123456;Initial Catalog={dbName};",
"Conn": "Data Source=127.0.0.1;User ID=root;Password=123456;Initial Catalog={dbName};",
"DbType": 0,
"IsAutoCloseConnection": true,
"DbName": "pbl_huaxiang" //代码生成默认连接数据库,Oracle库是实例的名称
},
"urls": "http://localhost:8888", //项目启动url如果改动端口前端对应devServer也需要进行修改
"urls": "http://0.0.0.0:8888", //项目启动url如果改动端口前端对应devServer也需要进行修改
"corsUrls": [ "http://localhost:8887", "http://localhost:8886" ], //跨域地址(前端启动项目,前后端分离单独部署需要设置),多个用","隔开
"JwtSettings": {
"Issuer": "DOANAdmin.NET", //即token的签发者。

View File

@@ -8,8 +8,8 @@
},
"dbConfigs": [
{
"Conn": "Data Source=LAPTOP-STKF2M8H\\SQLEXPRESS;User ID=admin;Password=123456;Initial Catalog=DOANAdmin;",
"DbType": 1, //数据库类型 MySql = 0, SqlServer = 1, Oracle = 3PgSql = 4
"Conn": "Data Source=127.0.0.1;User ID=root;Password=123456;Initial Catalog=pbl_huaxiang;",
"DbType": 0, //数据库类型 MySql = 0, SqlServer = 1, Oracle = 3PgSql = 4
"ConfigId": "0", //多租户唯一标识
"IsAutoCloseConnection": true
}
@@ -18,12 +18,12 @@
//代码生成数据库配置
"CodeGenDbConfig": {
//代码生成连接字符串,注意{dbName}为固定格式,不要填写数据库名
"Conn": "Data Source=LAPTOP-STKF2M8H\\SQLEXPRESS;User ID=admin;Password=admin123;Initial Catalog={dbName};",
"DbType": 1,
"Conn": "Data Source=127.0.0.1;User ID=admin;Password=admin123;Initial Catalog={dbName};",
"DbType": 0,
"IsAutoCloseConnection": true,
"DbName": "DOANAdmin" //代码生成默认连接数据库,Oracle库是实例的名称
"DbName": "pbl_huaxiang" //代码生成默认连接数据库,Oracle库是实例的名称
},
"urls": "http://localhost:8888", //项目启动url如果改动端口前端对应devServer也需要进行修改
"urls": "http://127.0.0.1:8888", //项目启动url如果改动端口前端对应devServer也需要进行修改
"corsUrls": [ "http://localhost:8887", "http://localhost:8886" ], //跨域地址(前端启动项目,前后端分离单独部署需要设置),多个用","隔开
"JwtSettings": {
"Issuer": "DOANAdmin.NET", //即token的签发者。

View File

@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DOAN.Model.PBL.Dto
{
public class LightUpDto
{
/// <summary>
/// 工单号
/// </summary>
public string Workorder { get; set; }
/// <summary>
/// 订单号
/// </summary>
public string OrderNumber { get; set; }
/// <summary>
/// 总成零件号
/// </summary>
public string AssemblyPartNumber { get; set; }
}
}

View File

@@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DOAN.Model.PBL
{
/// <summary>
/// 库存日志
/// </summary>
[SugarTable("light_log")]
public class Light_Log
{
/// <summary>
/// 雪花
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = false)]
public string Id { get; set; }
/// <summary>
/// 1亮灯、2灭灯
/// </summary>
[SugarColumn(ColumnName = "light_operation")]
public int LightOperation { get; set; }
/// <summary>
/// 货架号
/// </summary>
[SugarColumn(ColumnName = "shelf_code")]
public string ShelfCode { get; set; }
/// <summary>
/// 操作者
/// </summary>
[SugarColumn(ColumnName = "operationer")]
public string Operationer { get; set; }
/// <summary>
/// 创建时间
/// </summary>
[SugarColumn(ColumnName = "created_time")]
public DateTime? CreatedTime { get; set; }
}
}

View File

@@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DOAN.Model.PBL
{
/// <summary>
/// mes交互日志
/// </summary>
[SugarTable("mes_interation_log")]
public class MES_Interation_Log
{
/// <summary>
/// 雪花
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = false)]
public string Id { get; set; }
/// <summary>
/// 工单号
/// </summary>
[SugarColumn(ColumnName = "Workorder")]
public string Workorder { get; set; }
/// <summary>
/// 订单号
/// </summary>
[SugarColumn(ColumnName = "OrderNumber")]
public string OrderNumber { get; set; }
/// <summary>
/// 总成零件号
/// </summary>
[SugarColumn(ColumnName = "AssemblyPartNumber")]
public string AssemblyPartNumber { get; set; }
/// <summary>
/// 扫描scancode
/// </summary>
[SugarColumn(ColumnName = "scancode")]
public string ScanCode { get; set; }
[SugarColumn(ColumnName = "created_time")]
public DateTime CreatedTime { get; set; }
[SugarColumn(ColumnName = "updated_time")]
public DateTime UpdatedTime { get; set; }
}
}

View File

@@ -0,0 +1,17 @@
using DOAN.Model.PBL.Dto;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DOAN.Service.PBL.IService
{
public interface IMESInteractionServcie
{
bool MESLightUp(LightUpDto light);
bool MESLightDown(string scan_code);
}
}

View File

@@ -0,0 +1,109 @@
using Infrastructure.Attribute;
using Infrastructure.Extensions;
using DOAN.Model.PBL.Dto;
using DOAN.Model.PBL;
using DOAN.Repository;
using DOAN.Service.PBL.IService;
using Mapster;
using System.Runtime.InteropServices;
using SqlSugar;
using System.Security.Cryptography.X509Certificates;
namespace DOAN.Service.PBL
{
/// <summary>
/// 料架表Service业务层处理
/// </summary>
[AppService(ServiceType = typeof(IMESInteractionServcie), ServiceLifetime = LifeTime.Transient)]
public class MESInteractionServcie : BaseService<Storagelocation>, IMESInteractionServcie
{
public bool MESLightUp(LightUpDto light)
{
// 1.记录MES交互记录
MES_Interation_Log item = light.Adapt<MES_Interation_Log>();
item.Id = XUEHUA;
item.CreatedTime= DateTime.Now;
Context.Insertable(item).ExecuteCommand();
// 2.根据总成零件号 查询对应零件号,使得对应料架亮灯
//镜壳 料架
Storagelocation MirrorshellShelf = Context.Queryable<Storagelocation>().Where(it => it.Partnumber ==
SqlFunc.Subqueryable<Billofmaterials>().Where(It => It.Productcode == light.AssemblyPartNumber).Select(it => it.MirrorshellCode)).First();
//镜体 料架
Storagelocation MirrorshellBody = Context.Queryable<Storagelocation>().Where(it => it.Partnumber ==
SqlFunc.Subqueryable<Billofmaterials>().Where(It => It.Productcode == light.AssemblyPartNumber).Select(it => it.MirrorbodyCode)).First();
// 3.对应料架亮灯
Light_Log light_Log = new Light_Log();
light_Log.Id = XUEHUA;
light_Log.LightOperation = 1;
if (MirrorshellShelf != null)
{
light_Log.ShelfCode = MirrorshellShelf.RackCode;
}
light_Log.Operationer = "PBL";
light_Log.CreatedTime = DateTime.Now;
Light_Log light_Log2 = new Light_Log();
light_Log2.Id = XUEHUA;
light_Log2.LightOperation = 1;
if (MirrorshellShelf != null)
{
light_Log2.ShelfCode = MirrorshellShelf.RackCode;
}
light_Log2.Operationer = "PBL";
light_Log2.CreatedTime = DateTime.Now;
Context.Insertable(light_Log2).ExecuteCommand();
int result = Context.Insertable(light_Log).ExecuteCommand();
if (result > 0)
{
return true;
}
else
{
return false;
}
}
public bool MESLightDown(string scan_code)
{
// 1.记录MES交互记录
MES_Interation_Log item = new MES_Interation_Log();
item.Id = XUEHUA;
item.ScanCode=scan_code;
item.CreatedTime = DateTime.Now;
Context.Insertable(item).ExecuteCommand();
//2 找到对应的料架 灭灯
Storagelocation storagelocation= Context.Queryable<Storagelocation>().Where(it => it.Partnumber == scan_code).First();
Light_Log light_Log = new Light_Log();
light_Log.Id = XUEHUA;
light_Log.LightOperation = 2;
if (storagelocation != null) {
light_Log.ShelfCode = storagelocation.RackCode ;
}
light_Log.Operationer = "PBL";
light_Log.CreatedTime = DateTime.Now;
int result= Context.Insertable(light_Log).ExecuteCommand();
if (result > 0)
{
return true;
}
else
{
return false;
}
}
}
}

View File

@@ -85,7 +85,7 @@ namespace DOAN.ServiceCore.Middleware
#if DEBUG
if (logLevel == LogLevel.Error)
{
apiResult.Add("error", "请在issue里面寻找答案或者官方文档查看常见问题https://gitee.com/izory/DOANAdminNetCore/issues");
apiResult.Add("error", "请在issue里面寻找答案或者官方文档查看常见问题");
}
#endif
string responseResult = textJson.JsonSerializer.Serialize(apiResult, options);

View File

@@ -134,7 +134,7 @@ namespace DOAN.Common
//.net7需要这样写
var coherentState = Cache.GetType().GetField("_coherentState", flags).GetValue(Cache);
var entries = coherentState.GetType().GetField("_entries", flags).GetValue(coherentState);
var entries = coherentState.GetType()?.GetField("_entries", flags)?.GetValue(coherentState);
var keys = new List<string>();
if (entries is not IDictionary cacheItems) return keys;

View File

@@ -23,4 +23,26 @@
<PackageReference Include="IP2Region.Net" Version="2.0.2" />
</ItemGroup>
<ItemGroup>
<Reference Include="HslCommunication">
<HintPath>dll\HslCommunication.dll</HintPath>
</Reference>
<Reference Include="ICSharpCode.SharpZipLib">
<HintPath>..\..\..\..\..\=====项目标准目录=====\3-设备程序\X1F1-服务器参数配置-20230908\packages\ICSharpCode.SharpZipLib.0.86.0.518\lib\net45\ICSharpCode.SharpZipLib.dll</HintPath>
</Reference>
<Reference Include="NPOI">
<HintPath>..\..\..\..\..\=====项目标准目录=====\3-设备程序\X1F1-服务器参数配置-20230908\STBIN\RefAssembly\NPOI.dll</HintPath>
</Reference>
<Reference Include="NPOI.OOXML">
<HintPath>..\..\..\..\..\=====项目标准目录=====\3-设备程序\X1F1-服务器参数配置-20230908\STBIN\RefAssembly\NPOI.OOXML.dll</HintPath>
</Reference>
<Reference Include="NPOI.OpenXml4Net">
<HintPath>..\..\..\..\..\=====项目标准目录=====\3-设备程序\X1F1-服务器参数配置-20230908\STBIN\RefAssembly\NPOI.OpenXml4Net.dll</HintPath>
</Reference>
<Reference Include="Register">
<HintPath>dll\Register.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,32 @@
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Register;
namespace DOAN.Infrastructure.WebExtensions
{
public static class HslCommunicationExtension
{
public static void AddHslCommunication(this IServiceCollection services)
{
//if (!HslCommunication.Authorization.SetAuthorizationCode("71d19e25-1fc3-419f-adaa-8c14df37952a"))
//{
// Console.WriteLine("HslCommunication激活失败");
//}
if (!Register.Reg.RegLicense())
{
Console.WriteLine("HslCommunication激活失败");
}
else
{
Console.WriteLine("HslCommunication激活成功");
}
;
}
}
}

Binary file not shown.

Binary file not shown.