From 41d74577229fa4e40ec77e8b1886aad68dc73130 Mon Sep 17 00:00:00 2001 From: "liulb@mesnac.com" Date: Sun, 19 Nov 2023 22:27:14 +0800 Subject: [PATCH] . --- Admin.Core.Api/Admin.Core.Api.xml | 16 +- Admin.Core.Api/Admin.Core.Model.xml | 516 ++++++++++++++++-- .../Business/MaterialController.cs | 12 +- .../Controllers/Business/SolventController.cs | 27 +- .../Business/WarehouseController.cs | 14 +- .../PublishProfiles/FolderProfile1.pubxml | 4 + Admin.Core.Api/appsettings.Development.json | 11 +- Admin.Core.Api/appsettings.json | 12 +- .../Middlewares/QuartzJobMildd.cs | 6 +- .../IRepository_New/ILR_AlarmlogRepository.cs | 11 + .../IRepository_New/ILR_weighRepository.cs | 11 + .../IRepository_New/IPmt_AlarmRepository.cs | 11 + .../IService_New/IHw_WarehouseServices.cs | 2 +- .../IService_New/ILR_AlarmlogServices.cs | 12 + .../IService_New/ILR_weighServices.cs | 12 + .../IService_New/IPmt_AlarmServices.cs | 12 + .../Model_New/Hw_WareHouse_Sub.cs | 87 ++- Admin.Core.Model/Model_New/Hw_Warehouse.cs | 13 +- Admin.Core.Model/Model_New/LR_Alarmlog.cs | 59 ++ Admin.Core.Model/Model_New/LR_weigh.cs | 95 ++++ Admin.Core.Model/Model_New/Pmt_Alarm.cs | 79 +++ Admin.Core.Model/ViewModels/BarrelView.cs | 31 +- .../ViewModels/HwWareHouseSubView.cs | 97 ++++ Admin.Core.Model/ViewModels/KettleView.cs | 42 +- Admin.Core.Model/ViewModels/WarehouseView.cs | 21 +- .../Repository_New/Hw_weighRepository.cs | 2 +- .../Repository_New/LR_AlarmlogRepository.cs | 15 + .../Repository_New/LR_weighRepository.cs | 15 + .../Repository_New/Pmt_AlarmRepository.cs | 15 + .../Service_New/Hw_WarehouseServices.cs | 197 ++++--- .../Service_New/LR_AlarmlogServices.cs | 17 + .../Service_New/LR_weighServices.cs | 17 + .../Service_New/Pmt_AlarmServices.cs | 17 + .../Service_New/SolventServices.cs | 177 +++--- .../Service_New/xl_materialServices.cs | 26 +- .../QuartzNet/Jobs/Job_Admin_Quartz.cs | 84 ++- README (2).md | 18 - 37 files changed, 1461 insertions(+), 352 deletions(-) create mode 100644 Admin.Core.IRepository/IRepository_New/ILR_AlarmlogRepository.cs create mode 100644 Admin.Core.IRepository/IRepository_New/ILR_weighRepository.cs create mode 100644 Admin.Core.IRepository/IRepository_New/IPmt_AlarmRepository.cs create mode 100644 Admin.Core.IService/IService_New/ILR_AlarmlogServices.cs create mode 100644 Admin.Core.IService/IService_New/ILR_weighServices.cs create mode 100644 Admin.Core.IService/IService_New/IPmt_AlarmServices.cs create mode 100644 Admin.Core.Model/Model_New/LR_Alarmlog.cs create mode 100644 Admin.Core.Model/Model_New/LR_weigh.cs create mode 100644 Admin.Core.Model/Model_New/Pmt_Alarm.cs create mode 100644 Admin.Core.Model/ViewModels/HwWareHouseSubView.cs create mode 100644 Admin.Core.Repository/Repository_New/LR_AlarmlogRepository.cs create mode 100644 Admin.Core.Repository/Repository_New/LR_weighRepository.cs create mode 100644 Admin.Core.Repository/Repository_New/Pmt_AlarmRepository.cs create mode 100644 Admin.Core.Service/Service_New/LR_AlarmlogServices.cs create mode 100644 Admin.Core.Service/Service_New/LR_weighServices.cs create mode 100644 Admin.Core.Service/Service_New/Pmt_AlarmServices.cs delete mode 100644 README (2).md diff --git a/Admin.Core.Api/Admin.Core.Api.xml b/Admin.Core.Api/Admin.Core.Api.xml index 445da1c..1627ca5 100644 --- a/Admin.Core.Api/Admin.Core.Api.xml +++ b/Admin.Core.Api/Admin.Core.Api.xml @@ -307,9 +307,9 @@ 桶条码 - + - 测试 + 获取当前正在称量的物料 @@ -360,12 +360,6 @@ 拉缸Code - - - 获取所有溶剂计划 - - - 反应釜防错验证 @@ -383,11 +377,13 @@ - + 扫描料桶条码 获取桶绑定物料信息 - 桶条码 + 反应釜 + 计划Id + 料桶Id diff --git a/Admin.Core.Api/Admin.Core.Model.xml b/Admin.Core.Api/Admin.Core.Model.xml index d48ef20..734659e 100644 --- a/Admin.Core.Api/Admin.Core.Model.xml +++ b/Admin.Core.Api/Admin.Core.Model.xml @@ -643,7 +643,7 @@ - + 反应釜 @@ -655,23 +655,18 @@ - Desc:成品物料名称 + Desc:反应釜名称 Default: Nullable:True - Desc:条码Code + Desc:反应釜二维码 Default: Nullable:True - - - 反应釜计划号 - - Desc: @@ -691,11 +686,6 @@ 投料釜相关物料 - - - 构造函数 - - Desc:主键 @@ -705,19 +695,35 @@ - Desc:釜主键 + Desc: Default: Nullable:False - 计划号 + Desc:批次 + Default: + Nullable:True + + + + + Desc:产品名称 + Default: + Nullable:True - Desc:物料ID(废弃) + Desc:物料编码 + Default: + Nullable:True + + + + + Desc:二维码 Default: Nullable:True @@ -729,32 +735,84 @@ Nullable:True - + - Desc:条码 + Desc:所属料仓 + Default: + Nullable:True + + + + + Desc:物料类型:整包、尾料、溶剂 Default: Nullable:True - Desc:物料重量 + Desc:重量 Default: Nullable:True - 物料误差 + Desc:误差值 + Default: + Nullable:True + + + + + Desc:工装区分,相同值代表在一个料桶中 + Default: + Nullable:True + + + + + Desc:是否有固含 1为有,0没有 + Default:0 + Nullable:True + + + + + Desc:固含率 + Default: + Nullable:True + + + + + Desc:配方名 + Default: + Nullable:True + + + + + 备注 - Desc:创建时间 + Desc: Default: Nullable:True + + + 地磅 + + + + + 泵条码 + + @@ -837,6 +895,60 @@ Nullable:True + + + 报警记录 + + + + + Desc:主键 + Default: + Nullable:False + + + + + Desc:设备编码 + Default: + Nullable:True + + + + + Desc:预警编码 + Default: + Nullable:True + + + + + Desc:发生时间 + Default: + Nullable:True + + + + + Desc:清理时间 + Default: + Nullable:True + + + + + Desc:GUID + Default: + Nullable:True + + + + + Desc: + Default: + Nullable:True + + @@ -1038,6 +1150,175 @@ Nullable:True + + + + + + + + Desc: + Default: + Nullable:False + + + + + Desc: + Default: + Nullable:True + + + + + Desc: + Default: + Nullable:True + + + + + Desc: + Default: + Nullable:True + + + + + Desc: + Default: + Nullable:True + + + + + Desc: + Default: + Nullable:True + + + + + Desc: + Default: + Nullable:True + + + + + Desc: + Default: + Nullable:True + + + + + Desc: + Default: + Nullable:True + + + + + Desc: + Default: + Nullable:True + + + + + Desc: + Default: + Nullable:True + + + + + Desc:称量时间 + Default: + Nullable:True + + + + + Desc: + Default: + Nullable:True + + + + + + + + + + Desc: + Default: + Nullable:False + + + + + Desc: + Default: + Nullable:True + + + + + Desc: + Default: + Nullable:True + + + + + 点位 + + + + + Desc: + Default: + Nullable:True + + + + + Desc: + Default: + Nullable:True + + + + + Desc:中文名称 + Default: + Nullable:True + + + + + Desc: + Default: + Nullable:True + + + + + Desc: + Default: + Nullable:True + + + + + Desc: + Default: + Nullable:True + + @@ -3706,23 +3987,54 @@ Nullable:True - + + + 物料信息 + + + + + 物料信息 + + + Desc:物料ID Default: Nullable:True - + + + Desc:物料二维码 + Default: + Nullable:True + + + Desc:物料名称 Default: Nullable:True - + - Desc:绑定桶的物料重量 + Desc:物料重量 + Default: + Nullable:True + + + + + Desc:物料误差 + Default: + Nullable:True + + + + + Desc:是否验证 Default: Nullable:True @@ -3807,6 +4119,102 @@ 类型 :整包、称量 + + + 反应釜类型子表 + + + + + Desc:主键 + Default: + Nullable:False + + + + + Desc: + Default: + Nullable:False + + + + + Desc:批次 + Default: + Nullable:True + + + + + Desc:产品名称 + Default: + Nullable:True + + + + + Desc:物料编码 + Default: + Nullable:True + + + + + Desc:二维码 + Default: + Nullable:True + + + + + Desc:物料名称 + Default: + Nullable:True + + + + + Desc:所属料仓 + Default: + Nullable:True + + + + + Desc:物料类型:整包、尾料、溶剂 + Default: + Nullable:True + + + + + Desc:重量 + Default: + Nullable:True + + + + + Desc:误差值 + Default: + Nullable:True + + + + + Desc:工装区分,相同值代表在一个料桶中 + Default: + Nullable:True + + + + + Desc:配方名 + Default: + Nullable:True + + 投料釜匹配完成传入参数 @@ -3827,32 +4235,47 @@ 投料釜条码 - + - 料桶条码 + 状态 0:未扫描 1:匹配 2:报警 - + - 物料条码 + 投入物料详细 - + - 物料重量 + 物料详细 - + 物料类型:整包、散装 - + - 状态 0:未扫描 1:匹配 2:报警 + 料桶条码 + + + + + 物料条码 - + + + 物料名称 + + + + + 实际物料重量 + + + 投料整包完整信息 @@ -4377,6 +4800,11 @@ 子菜单 + + + 主键 + + 计划ID @@ -4384,28 +4812,14 @@ - Desc:成品物料名称 + Desc:反应釜名称 Default: Nullable:True - Desc:条码Code - Default: - Nullable:True - - - - - Desc: - Default: - Nullable:True - - - - - Desc:更新时间 + Desc:反应釜二维码 Default: Nullable:True diff --git a/Admin.Core.Api/Controllers/Business/MaterialController.cs b/Admin.Core.Api/Controllers/Business/MaterialController.cs index 35e0b11..1650416 100644 --- a/Admin.Core.Api/Controllers/Business/MaterialController.cs +++ b/Admin.Core.Api/Controllers/Business/MaterialController.cs @@ -154,6 +154,7 @@ namespace Admin.Core.Api /// /// 桶条码 /// + [Obsolete("废弃")] [HttpGet] public async Task> BindBarrel(string code) { @@ -188,17 +189,16 @@ namespace Admin.Core.Api } #endregion - #region 测试 + #region 获取当前正在称量的物料 /// - /// 测试 + /// 获取当前正在称量的物料 /// /// [HttpGet] - public Task BindBarrel2() + public Task> GetCurrentMaterial() { - decimal we2 = Convert.ToDecimal(Adapter.ReadInt16("DB104.DBW164")) / 100;//检量秤重量 - int tcheckBatch = Adapter.ReadInt32("DB110.DBW212");//当前执行的车次 - return Task.FromResult(tcheckBatch); + MessageModel ms=new MessageModel(); + return Task.FromResult(ms); } #endregion diff --git a/Admin.Core.Api/Controllers/Business/SolventController.cs b/Admin.Core.Api/Controllers/Business/SolventController.cs index cdc1dc1..8da7f23 100644 --- a/Admin.Core.Api/Controllers/Business/SolventController.cs +++ b/Admin.Core.Api/Controllers/Business/SolventController.cs @@ -56,7 +56,7 @@ namespace Admin.Core.Api var query = await _solventServices.GetByCylinderCode(code.Trim(),weighbridge.Trim()); if (query == null) { - return Failed("查询失败!"); + return Failed("未查询到计划信息!"); } return Success(query); } @@ -136,29 +136,6 @@ namespace Admin.Core.Api } #endregion - #region 获取所有溶剂计划 - /// - /// 获取所有溶剂计划 - /// - /// - [HttpGet] - [Obsolete("废弃")] - public async Task>> GetSolventPlanInfo() - { - MessageModel> message = new MessageModel>(); - var list = await _solventServices.GetSolventPlanInfo(); - if (list.Count > 0) - { - message.success = true; - message.data = list; - } - else - { - message.success = false; - message.msg = "未查询到计划数据!"; - } - return message; - } - #endregion + } } \ No newline at end of file diff --git a/Admin.Core.Api/Controllers/Business/WarehouseController.cs b/Admin.Core.Api/Controllers/Business/WarehouseController.cs index a5a6da5..76441f3 100644 --- a/Admin.Core.Api/Controllers/Business/WarehouseController.cs +++ b/Admin.Core.Api/Controllers/Business/WarehouseController.cs @@ -37,6 +37,7 @@ namespace Admin.Core.Api.Controllers.Business /// private readonly IHw_WarehouseServices _hw_WarehouseService; + #region 构造方法 /// /// 构造方法 /// @@ -48,20 +49,24 @@ namespace Admin.Core.Api.Controllers.Business _hw_WarehouseService = hw_WarehouseServices; } + #endregion + #region 扫描料桶条码 获取桶绑定物料信息 /// /// 扫描料桶条码 获取桶绑定物料信息 /// - /// 桶条码 + /// 反应釜 + /// 计划Id + /// 料桶Id /// [HttpGet] - public async Task> GetByBarrelInfo(string code) + public async Task> GetByBarrelInfo(string kettleBarCode, string planId,string code) { if (!code.IsNotEmptyOrNull()) { return Failed("传入参数为空!"); } - var query = await _hw_WarehouseService.GetXlInfo(code.Trim()); + var query = await _hw_WarehouseService.GetXlInfo(kettleBarCode.Trim(),planId.Trim(),code.Trim()); if (query == null) { return Failed("查询失败!"); @@ -121,7 +126,6 @@ namespace Admin.Core.Api.Controllers.Business } #endregion - #region 查询反应釜计划 /// /// 查询反应釜计划 @@ -143,7 +147,5 @@ namespace Admin.Core.Api.Controllers.Business return Success(list); } #endregion - - } } \ No newline at end of file diff --git a/Admin.Core.Api/Properties/PublishProfiles/FolderProfile1.pubxml b/Admin.Core.Api/Properties/PublishProfiles/FolderProfile1.pubxml index 0278a2b..baf6ca7 100644 --- a/Admin.Core.Api/Properties/PublishProfiles/FolderProfile1.pubxml +++ b/Admin.Core.Api/Properties/PublishProfiles/FolderProfile1.pubxml @@ -13,5 +13,9 @@ https://go.microsoft.com/fwlink/?LinkID=208121. E:\发布文件 FileSystem <_TargetId>Folder + + net6.0 + 4d119349-9b79-489b-8e25-0f314b0693ba + false \ No newline at end of file diff --git a/Admin.Core.Api/appsettings.Development.json b/Admin.Core.Api/appsettings.Development.json index ec3f4f9..f8ae61e 100644 --- a/Admin.Core.Api/appsettings.Development.json +++ b/Admin.Core.Api/appsettings.Development.json @@ -61,7 +61,6 @@ // 请配置MainDB为你想要的主库的ConnId值,并设置对应的Enabled为true; // *** 单库操作,把 MutiDBEnabled 设为false ***; // *** 多库操作,把 MutiDBEnabled 设为true,其他的从库Enabled也为true **; - // 具体配置看视频:https://www.bilibili.com/video/BV1BJ411B7mn?p=6 "MainDB": "ADMIN_SQLITE", //当前项目的主库,所对应的连接字符串的Enabled必须为true "MutiDBEnabled": false, //是否开启多库模式 "CQRSEnabled": false, //是否开启读写分离模式,必须是单库模式,且数据库类型一致,比如都是SqlServer @@ -81,11 +80,8 @@ "DBType": 1, "Enabled": true, "HitRate": 50, - //"Connection": "Server=127.0.0.1;Port=5432;User Id=postgres;Password=postgres;Database=Admin.Core;", - "Connection": "Data Source=localhost;Initial Catalog=cwss_xl;User ID=sa;Password=sa;Integrated Security=false;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", - //"Connection": "Data Source=.;Initial Catalog=RCEP_Market;User ID=sa;Password=Password01!;Integrated Security=false;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", - //"Connection": "db/hw.db", - + //"Connection": "Data Source=121.36.58.109;Initial Catalog=cwss_xl;User ID=sa;Password=haiwei@123;Integrated Security=false;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", + "Connection": "Data Source=192.168.10.50;Initial Catalog=cwss_xl;User ID=sa;Password=sa;Integrated Security=false;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", "ProviderName": "System.Data.SqlClient" } ], @@ -117,7 +113,6 @@ } }, "Redis": { - //"ConnectionString": "127.0.0.1:6379" "ConnectionString": "127.0.0.1:6379" }, "RabbitMQ": { @@ -173,7 +168,7 @@ { "Id": 2, "EquipName": "溶剂PLC", - "IP": "127.0.0.1", + "IP": "192.168.10.130", "Port": 102 } ], diff --git a/Admin.Core.Api/appsettings.json b/Admin.Core.Api/appsettings.json index b196aa1..7e7f1e2 100644 --- a/Admin.Core.Api/appsettings.json +++ b/Admin.Core.Api/appsettings.json @@ -61,7 +61,6 @@ // 请配置MainDB为你想要的主库的ConnId值,并设置对应的Enabled为true; // *** 单库操作,把 MutiDBEnabled 设为false ***; // *** 多库操作,把 MutiDBEnabled 设为true,其他的从库Enabled也为true **; - // 具体配置看视频:https://www.bilibili.com/video/BV1BJ411B7mn?p=6 "MainDB": "ADMIN_SQLITE", //当前项目的主库,所对应的连接字符串的Enabled必须为true "MutiDBEnabled": false, //是否开启多库模式 "CQRSEnabled": false, //是否开启读写分离模式,必须是单库模式,且数据库类型一致,比如都是SqlServer @@ -81,11 +80,7 @@ "DBType": 1, "Enabled": true, "HitRate": 50, - //"Connection": "Server=127.0.0.1;Port=5432;User Id=postgres;Password=postgres;Database=Admin.Core;", - "Connection": "Data Source=localhost;Initial Catalog=cwss_xl;User ID=sa;Password=sa;Integrated Security=false;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", - //"Connection": "Data Source=.;Initial Catalog=RCEP_Market;User ID=sa;Password=Password01!;Integrated Security=false;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", - //"Connection": "db/hw.db", - + "Connection": "Data Source=192.168.10.50;Initial Catalog=cwss_xl;User ID=sa;Password=sa;Integrated Security=false;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", "ProviderName": "System.Data.SqlClient" } ], @@ -117,7 +112,6 @@ } }, "Redis": { - //"ConnectionString": "127.0.0.1:6379" "ConnectionString": "127.0.0.1:6379" }, "RabbitMQ": { @@ -167,13 +161,13 @@ { "Id": 1, "EquipName": "小料PLC", - "IP": "127.0.0.1", + "IP": "192.168.10.100", "Port": 102 }, { "Id": 2, "EquipName": "溶剂PLC", - "IP": "127.0.0.1", + "IP": "192.168.10.130", "Port": 102 } ], diff --git a/Admin.Core.Extensions/Middlewares/QuartzJobMildd.cs b/Admin.Core.Extensions/Middlewares/QuartzJobMildd.cs index da51152..370ae74 100644 --- a/Admin.Core.Extensions/Middlewares/QuartzJobMildd.cs +++ b/Admin.Core.Extensions/Middlewares/QuartzJobMildd.cs @@ -3,9 +3,7 @@ using Admin.Core.IService.ISys; using Admin.Core.Tasks; using log4net; using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; using System; -using System.Threading.Tasks; namespace Admin.Core.Extensions { @@ -15,7 +13,7 @@ namespace Admin.Core.Extensions public static class QuartzJobMildd { private static readonly ILog log = LogManager.GetLogger(typeof(QuartzJobMildd)); - public static async Task UseQuartzJobMildd(this IApplicationBuilder app, ISysTasksQzService tasksQzService, ISchedulerCenter schedulerCenter) + public static void UseQuartzJobMildd(this IApplicationBuilder app, ISysTasksQzService tasksQzService, ISchedulerCenter schedulerCenter) { if (app == null) throw new ArgumentNullException(nameof(app)); @@ -24,7 +22,7 @@ namespace Admin.Core.Extensions if (Appsettings.app("Middleware", "QuartzNetJob", "Enabled").ObjToBool()) { //**注意在此处查询《wpf异步查询不到改为同步》** - var allQzServices =await tasksQzService.QueryAsync(x => x.DelFlag == false); + var allQzServices =tasksQzService.Query(x => x.DelFlag == false); foreach (var item in allQzServices) { if ((bool)item.IsStart) diff --git a/Admin.Core.IRepository/IRepository_New/ILR_AlarmlogRepository.cs b/Admin.Core.IRepository/IRepository_New/ILR_AlarmlogRepository.cs new file mode 100644 index 0000000..9e22172 --- /dev/null +++ b/Admin.Core.IRepository/IRepository_New/ILR_AlarmlogRepository.cs @@ -0,0 +1,11 @@ +using Admin.Core.Model; + +namespace Admin.Core.IRepository +{ + /// + /// ILR_AlarmlogRepository + /// + public interface ILR_AlarmlogRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/Admin.Core.IRepository/IRepository_New/ILR_weighRepository.cs b/Admin.Core.IRepository/IRepository_New/ILR_weighRepository.cs new file mode 100644 index 0000000..a75d100 --- /dev/null +++ b/Admin.Core.IRepository/IRepository_New/ILR_weighRepository.cs @@ -0,0 +1,11 @@ +using Admin.Core.Model; + +namespace Admin.Core.IRepository +{ + /// + /// ILR_weighRepository + /// + public interface ILR_weighRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/Admin.Core.IRepository/IRepository_New/IPmt_AlarmRepository.cs b/Admin.Core.IRepository/IRepository_New/IPmt_AlarmRepository.cs new file mode 100644 index 0000000..fb9e215 --- /dev/null +++ b/Admin.Core.IRepository/IRepository_New/IPmt_AlarmRepository.cs @@ -0,0 +1,11 @@ +using Admin.Core.Model; + +namespace Admin.Core.IRepository +{ + /// + /// IPmt_AlarmRepository + /// + public interface IPmt_AlarmRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/Admin.Core.IService/IService_New/IHw_WarehouseServices.cs b/Admin.Core.IService/IService_New/IHw_WarehouseServices.cs index 2ae646b..20c5999 100644 --- a/Admin.Core.IService/IService_New/IHw_WarehouseServices.cs +++ b/Admin.Core.IService/IService_New/IHw_WarehouseServices.cs @@ -14,7 +14,7 @@ namespace Admin.Core.IService { Task QueryByCode(string code,string planId); Task UpdatePlcState(KettleView view); - Task GetXlInfo(string code); + Task GetXlInfo(string kettleBarCode, string planId, string code); Task> GetWarehousePlan(string code); } } \ No newline at end of file diff --git a/Admin.Core.IService/IService_New/ILR_AlarmlogServices.cs b/Admin.Core.IService/IService_New/ILR_AlarmlogServices.cs new file mode 100644 index 0000000..c711c0e --- /dev/null +++ b/Admin.Core.IService/IService_New/ILR_AlarmlogServices.cs @@ -0,0 +1,12 @@ +using Admin.Core.IService; +using Admin.Core.Model; + +namespace Admin.Core.IService +{ + /// + /// ILR_AlarmlogServices + /// + public interface ILR_AlarmlogServices :IBaseServices + { + } +} \ No newline at end of file diff --git a/Admin.Core.IService/IService_New/ILR_weighServices.cs b/Admin.Core.IService/IService_New/ILR_weighServices.cs new file mode 100644 index 0000000..d55505f --- /dev/null +++ b/Admin.Core.IService/IService_New/ILR_weighServices.cs @@ -0,0 +1,12 @@ +using Admin.Core.IService; +using Admin.Core.Model; + +namespace Admin.Core.IService +{ + /// + /// ILR_weighServices + /// + public interface ILR_weighServices :IBaseServices + { + } +} \ No newline at end of file diff --git a/Admin.Core.IService/IService_New/IPmt_AlarmServices.cs b/Admin.Core.IService/IService_New/IPmt_AlarmServices.cs new file mode 100644 index 0000000..86562aa --- /dev/null +++ b/Admin.Core.IService/IService_New/IPmt_AlarmServices.cs @@ -0,0 +1,12 @@ +using Admin.Core.IService; +using Admin.Core.Model; + +namespace Admin.Core.IService +{ + /// + /// IPmt_AlarmServices + /// + public interface IPmt_AlarmServices :IBaseServices + { + } +} \ No newline at end of file diff --git a/Admin.Core.Model/Model_New/Hw_WareHouse_Sub.cs b/Admin.Core.Model/Model_New/Hw_WareHouse_Sub.cs index fe22b66..734ddb8 100644 --- a/Admin.Core.Model/Model_New/Hw_WareHouse_Sub.cs +++ b/Admin.Core.Model/Model_New/Hw_WareHouse_Sub.cs @@ -1,4 +1,5 @@ using System; +using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Text; using SqlSugar; @@ -10,14 +11,11 @@ namespace Admin.Core.Model ///投料釜相关物料 /// [SugarTable("Hw_WareHouse_Sub", "cwss_xl")] + /// + ///反应釜计划 + /// public class Hw_WareHouse_Sub { - /// - /// 构造函数 - /// - public Hw_WareHouse_Sub() - { - } /// /// Desc:主键 /// Default: @@ -26,49 +24,108 @@ namespace Admin.Core.Model [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] public int ID { get; set; } /// - /// Desc:釜主键 + /// Desc: /// Default: /// Nullable:False /// public int MainId { get; set; } /// - /// 计划号 + /// Desc:批次 + /// Default: + /// Nullable:True /// public string PId { get; set; } /// - /// Desc:物料ID(废弃) + /// Desc:产品名称 + /// Default: + /// Nullable:True + /// + public string ProductName { get; set; } + /// + /// Desc:物料编码 /// Default: /// Nullable:True /// public string MaterialID { get; set; } /// + /// Desc:二维码 + /// Default: + /// Nullable:True + /// + public string Material_Code { get; set; } + /// /// Desc:物料名称 /// Default: /// Nullable:True /// public string MaterialName { get; set; } /// - /// Desc:条码 + /// Desc:所属料仓 /// Default: /// Nullable:True /// - public string Material_Code { get; set; } + public int BinId { get; set; } /// - /// Desc:物料重量 + /// Desc:物料类型:整包、尾料、溶剂 + /// Default: + /// Nullable:True + /// + public string MaterialType { get; set; } + /// + /// Desc:重量 /// Default: /// Nullable:True /// public decimal SetWeight { get; set; } /// - /// 物料误差 + /// Desc:误差值 + /// Default: + /// Nullable:True /// public decimal SetError { get; set; } - /// - /// Desc:创建时间 + /// Desc:工装区分,相同值代表在一个料桶中 + /// Default: + /// Nullable:True + /// + public string Difference { get; set; } + /// + /// Desc:是否有固含 1为有,0没有 + /// Default:0 + /// Nullable:True + /// + public bool Fixed { get; set; } + /// + /// Desc:固含率 + /// Default: + /// Nullable:True + /// + public decimal FixedRatio { get; set; } + /// + /// Desc:配方名 + /// Default: + /// Nullable:True + /// + public string Recipe { get; set; } + /// + /// 备注 + /// + public string Remark { get; set; } + /// + /// Desc: /// Default: /// Nullable:True /// public DateTime? CreateTime { get; set; } + /// + /// 地磅 + /// + + public string Weighbridge { get; set; } + /// + /// 泵条码 + /// + + public string PumpCode { get; set; } } } \ No newline at end of file diff --git a/Admin.Core.Model/Model_New/Hw_Warehouse.cs b/Admin.Core.Model/Model_New/Hw_Warehouse.cs index 1d3cf96..1da3562 100644 --- a/Admin.Core.Model/Model_New/Hw_Warehouse.cs +++ b/Admin.Core.Model/Model_New/Hw_Warehouse.cs @@ -9,14 +9,11 @@ using SqlSugar; namespace Admin.Core.Model { /// - /// + ///反应釜 /// [SugarTable("Hw_Warehouse", "cwss_xl")] public class Hw_Warehouse { - public Hw_Warehouse() - { - } /// /// Desc: /// Default: @@ -25,22 +22,18 @@ namespace Admin.Core.Model [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] public int ID { get; set; } /// - /// Desc:成品物料名称 + /// Desc:反应釜名称 /// Default: /// Nullable:True /// public string Name { get; set; } /// - /// Desc:条码Code + /// Desc:反应釜二维码 /// Default: /// Nullable:True /// public string BarCode { get; set; } /// - /// 反应釜计划号 - /// - public string PlanId { get; set; } - /// /// Desc: /// Default: /// Nullable:True diff --git a/Admin.Core.Model/Model_New/LR_Alarmlog.cs b/Admin.Core.Model/Model_New/LR_Alarmlog.cs new file mode 100644 index 0000000..871438a --- /dev/null +++ b/Admin.Core.Model/Model_New/LR_Alarmlog.cs @@ -0,0 +1,59 @@ +using System; +using System.Linq; +using System.Text; +using SqlSugar; + +namespace Admin.Core.Model +{ + /// + ///报警记录 + /// + [SugarTable("LR_Alarmlog", "cwss_xl")] + public class LR_Alarmlog + { + /// + /// Desc:主键 + /// Default: + /// Nullable:False + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int ID { get; set; } + /// + /// Desc:设备编码 + /// Default: + /// Nullable:True + /// + public string Equip_Code { get; set; } + /// + /// Desc:预警编码 + /// Default: + /// Nullable:True + /// + public int? Alarm_ID { get; set; } + + /// + /// Desc:发生时间 + /// Default: + /// Nullable:True + /// + public string Alarm_OccurTime { get; set; } + /// + /// Desc:清理时间 + /// Default: + /// Nullable:True + /// + public string Alarm_ClearTime { get; set; } + /// + /// Desc:GUID + /// Default: + /// Nullable:True + /// + public int? Alarm_Status { get; set; } + /// + /// Desc: + /// Default: + /// Nullable:True + /// + public string Alarm_GUID { get; set; } + } +} \ No newline at end of file diff --git a/Admin.Core.Model/Model_New/LR_weigh.cs b/Admin.Core.Model/Model_New/LR_weigh.cs new file mode 100644 index 0000000..d41fd1b --- /dev/null +++ b/Admin.Core.Model/Model_New/LR_weigh.cs @@ -0,0 +1,95 @@ +using System; +using System.Linq; +using System.Text; +using SqlSugar; + + +namespace Admin.Core.Model +{ + /// + /// + /// + [SugarTable("LR_weigh", "cwss_xl")] + public class LR_weigh + { + /// + /// Desc: + /// Default: + /// Nullable:False + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int ID { get; set; } + /// + /// Desc: + /// Default: + /// Nullable:True + /// + public string Dosing_ID { get; set; } + /// + /// Desc: + /// Default: + /// Nullable:True + /// + public string Plan_ID { get; set; } + /// + /// Desc: + /// Default: + /// Nullable:True + /// + public string Recipe_ID { get; set; } + /// + /// Desc: + /// Default: + /// Nullable:True + /// + public int? Bin_Serial { get; set; } + /// + /// Desc: + /// Default: + /// Nullable:True + /// + public string Material_ID { get; set; } + /// + /// Desc: + /// Default: + /// Nullable:True + /// + public string Material_Name { get; set; } + /// + /// Desc: + /// Default: + /// Nullable:True + /// + public string Set_Weight { get; set; } + /// + /// Desc: + /// Default: + /// Nullable:True + /// + public string Set_Error { get; set; } + /// + /// Desc: + /// Default: + /// Nullable:True + /// + public decimal? Real_Weight { get; set; } + /// + /// Desc: + /// Default: + /// Nullable:True + /// + public decimal? Real_Error { get; set; } + /// + /// Desc:称量时间 + /// Default: + /// Nullable:True + /// + public string EndTime { get; set; } + /// + /// Desc: + /// Default: + /// Nullable:True + /// + public int MainId { get; set; } + } +} \ No newline at end of file diff --git a/Admin.Core.Model/Model_New/Pmt_Alarm.cs b/Admin.Core.Model/Model_New/Pmt_Alarm.cs new file mode 100644 index 0000000..49d1996 --- /dev/null +++ b/Admin.Core.Model/Model_New/Pmt_Alarm.cs @@ -0,0 +1,79 @@ +using System; +using System.Linq; +using System.Text; +using SqlSugar; + + +namespace Admin.Core.Model +{ + /// + /// + /// + [SugarTable("Pmt_Alarm", "cwss_xl")] + public class Pmt_Alarm + { + public Pmt_Alarm() + { + } + /// + /// Desc: + /// Default: + /// Nullable:False + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int Alarm_ID { get; set; } + /// + /// Desc: + /// Default: + /// Nullable:True + /// + public string Equip_Code { get; set; } + /// + /// Desc: + /// Default: + /// Nullable:True + /// + public string Alarm_PLC { get; set; } + /// + /// 点位 + /// + public string Alarm_Point { get; set; } + + /// + /// Desc: + /// Default: + /// Nullable:True + /// + public int? Alarm_Block { get; set; } + /// + /// Desc: + /// Default: + /// Nullable:True + /// + public string Alarm_Alias { get; set; } + /// + /// Desc:中文名称 + /// Default: + /// Nullable:True + /// + public string Alarm_Cn_Info { get; set; } + /// + /// Desc: + /// Default: + /// Nullable:True + /// + public string Alarm_En_Info { get; set; } + /// + /// Desc: + /// Default: + /// Nullable:True + /// + public int? Alarm_Level { get; set; } + /// + /// Desc: + /// Default: + /// Nullable:True + /// + public string Alarm_Word { get; set; } + } +} \ No newline at end of file diff --git a/Admin.Core.Model/ViewModels/BarrelView.cs b/Admin.Core.Model/ViewModels/BarrelView.cs index 91ae445..0606550 100644 --- a/Admin.Core.Model/ViewModels/BarrelView.cs +++ b/Admin.Core.Model/ViewModels/BarrelView.cs @@ -31,6 +31,17 @@ namespace Admin.Core.Model.ViewModels /// Nullable:True /// public string BarCode { get; set; } + /// + /// 物料信息 + /// + public List child { get; set; } + + } + /// + /// 物料信息 + /// + public class MaterialView + { /// /// Desc:物料ID /// Default: @@ -38,16 +49,34 @@ namespace Admin.Core.Model.ViewModels /// public string MaterialID { get; set; } /// + /// Desc:物料二维码 + /// Default: + /// Nullable:True + /// + public string MaterialBarCode { get; set; } + /// /// Desc:物料名称 /// Default: /// Nullable:True /// public string MaterialName { get; set; } /// - /// Desc:绑定桶的物料重量 + /// Desc:物料重量 /// Default: /// Nullable:True /// public decimal? Weight { get; set; } + /// + /// Desc:物料误差 + /// Default: + /// Nullable:True + /// + public decimal? Error { get; set; } + /// + /// Desc:是否验证 + /// Default: + /// Nullable:True + /// + public int MatchOrNot { get; set; } } } diff --git a/Admin.Core.Model/ViewModels/HwWareHouseSubView.cs b/Admin.Core.Model/ViewModels/HwWareHouseSubView.cs new file mode 100644 index 0000000..72b1a55 --- /dev/null +++ b/Admin.Core.Model/ViewModels/HwWareHouseSubView.cs @@ -0,0 +1,97 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Admin.Core.Model.ViewModels +{ + /// + /// 反应釜类型子表 + /// + public class HwWareHouseSubView + { + /// + /// Desc:主键 + /// Default: + /// Nullable:False + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int ID { get; set; } + /// + /// Desc: + /// Default: + /// Nullable:False + /// + public int MainId { get; set; } + /// + /// Desc:批次 + /// Default: + /// Nullable:True + /// + public string PId { get; set; } + /// + /// Desc:产品名称 + /// Default: + /// Nullable:True + /// + public string ProductName { get; set; } + /// + /// Desc:物料编码 + /// Default: + /// Nullable:True + /// + public string MaterialID { get; set; } + /// + /// Desc:二维码 + /// Default: + /// Nullable:True + /// + public string Material_Code { get; set; } + /// + /// Desc:物料名称 + /// Default: + /// Nullable:True + /// + public string MaterialName { get; set; } + /// + /// Desc:所属料仓 + /// Default: + /// Nullable:True + /// + public int BinId { get; set; } + /// + /// Desc:物料类型:整包、尾料、溶剂 + /// Default: + /// Nullable:True + /// + public string MaterialType { get; set; } + /// + /// Desc:重量 + /// Default: + /// Nullable:True + /// + public decimal SetWeight { get; set; } + /// + /// Desc:误差值 + /// Default: + /// Nullable:True + /// + public decimal SetError { get; set; } + /// + /// Desc:工装区分,相同值代表在一个料桶中 + /// Default: + /// Nullable:True + /// + public string Difference { get; set; } + + /// + /// Desc:配方名 + /// Default: + /// Nullable:True + /// + public string Recipe { get; set; } + + } +} diff --git a/Admin.Core.Model/ViewModels/KettleView.cs b/Admin.Core.Model/ViewModels/KettleView.cs index 15fcee8..2267fd3 100644 --- a/Admin.Core.Model/ViewModels/KettleView.cs +++ b/Admin.Core.Model/ViewModels/KettleView.cs @@ -1,15 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; namespace Admin.Core.Model.ViewModels { /// /// 投料釜匹配完成传入参数 /// - public class KettleView + public class KettleView { /// /// 釜工位——主键 @@ -24,6 +20,24 @@ namespace Admin.Core.Model.ViewModels /// public string KCode { get; set; } /// + /// 状态 0:未扫描 1:匹配 2:报警 + /// + public int State { get; set; } + /// + /// 投入物料详细 + /// + public List Child { get; set; } + } + /// + /// 物料详细 + /// + public class MaterialList + { + /// + /// 物料类型:整包、散装 + /// + public string MatType { get; set; } + /// /// 料桶条码 /// public string BarrelCode { get; set; } @@ -32,21 +46,17 @@ namespace Admin.Core.Model.ViewModels /// public string MatCode { get; set; } /// - /// 物料重量 - /// - public decimal MatWeight { get; set; } - /// - /// 物料类型:整包、散装 + /// 物料名称 /// - public string MatType { get; set; } + public string MatName { get; set; } + /// - /// 状态 0:未扫描 1:匹配 2:报警 + /// 实际物料重量 /// - public int State { get; set; } + public double MatWeight { get; set; } /// /// 投料整包完整信息 /// public string WholePackage { get; set; } - } -} +} \ No newline at end of file diff --git a/Admin.Core.Model/ViewModels/WarehouseView.cs b/Admin.Core.Model/ViewModels/WarehouseView.cs index d40f755..d019246 100644 --- a/Admin.Core.Model/ViewModels/WarehouseView.cs +++ b/Admin.Core.Model/ViewModels/WarehouseView.cs @@ -8,38 +8,29 @@ namespace Admin.Core.Model.ViewModels { public class WarehouseView { + /// + /// 主键 + /// public int ID { get; set; } /// /// 计划ID /// public string PlanId { get; set; } /// - /// Desc:成品物料名称 + /// Desc:反应釜名称 /// Default: /// Nullable:True /// public string Name { get; set; } /// - /// Desc:条码Code + /// Desc:反应釜二维码 /// Default: /// Nullable:True /// public string BarCode { get; set; } /// - /// Desc: - /// Default: - /// Nullable:True - /// - public string CreateTime { get; set; } - /// - /// Desc:更新时间 - /// Default: - /// Nullable:True - /// - public string UpdateTime { get; set; } - /// /// 子菜单 /// - public List Children { get; set; } = new List(); + public List Children { get; set; } = new List(); } } diff --git a/Admin.Core.Repository/Repository_New/Hw_weighRepository.cs b/Admin.Core.Repository/Repository_New/Hw_weighRepository.cs index 96e4446..56f7ff3 100644 --- a/Admin.Core.Repository/Repository_New/Hw_weighRepository.cs +++ b/Admin.Core.Repository/Repository_New/Hw_weighRepository.cs @@ -20,7 +20,7 @@ namespace Admin.Core.Repository string sql = @"select w.Weight_Id MID,p.Plan_Id,p.Plan_Num,p.Real_Num,p.Plan_Serial,p.Plan_State,p.Plan_Date,p.Plan_StateText,r.ID as RecipeID,r.Recipe_Serial,r.Recipe_Name,r.Version,r.Recipe_Verify,r.Total_Weight,r.Total_Error,m.ID as MaterialID,m.Material_name,m.Material_code,w.Set_Weight,w.Set_Error, hw.Plan_ID MaterialPlan,ISNULL(w.IsRate,0) as Exist from RT_plan p left join Pmt_recipe r on p.Recipe_ID=r.ID left join Pmt_weigh w on r.ID=w.Recipe_ID left join Pmt_material m on w.Material_ID=m.ID - left join Hw_weigh hw on hw.Material_ID=m.ID and p.Real_Num=hw.Dosing_ID where p.Plan_State=3 and p.Plan_Id=@Plan_Id ORDER BY w.Weight_Id"; + left join Hw_weigh hw on hw.Plan_ID=p.Plan_Id and p.Real_Num=hw.Dosing_ID where p.Plan_State=3 and p.Plan_Id=@Plan_Id ORDER BY w.Weight_Id"; SugarParameter[] parameters = new SugarParameter[] { diff --git a/Admin.Core.Repository/Repository_New/LR_AlarmlogRepository.cs b/Admin.Core.Repository/Repository_New/LR_AlarmlogRepository.cs new file mode 100644 index 0000000..44d426f --- /dev/null +++ b/Admin.Core.Repository/Repository_New/LR_AlarmlogRepository.cs @@ -0,0 +1,15 @@ +using Admin.Core.IRepository; +using Admin.Core.Model; + +namespace Admin.Core.Repository +{ + /// + /// LR_AlarmlogRepository + /// + public class LR_AlarmlogRepository : BaseRepository, ILR_AlarmlogRepository + { + public LR_AlarmlogRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/Admin.Core.Repository/Repository_New/LR_weighRepository.cs b/Admin.Core.Repository/Repository_New/LR_weighRepository.cs new file mode 100644 index 0000000..3cc807b --- /dev/null +++ b/Admin.Core.Repository/Repository_New/LR_weighRepository.cs @@ -0,0 +1,15 @@ +using Admin.Core.IRepository; +using Admin.Core.Model; + +namespace Admin.Core.Repository +{ + /// + /// LR_weighRepository + /// + public class LR_weighRepository : BaseRepository, ILR_weighRepository + { + public LR_weighRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/Admin.Core.Repository/Repository_New/Pmt_AlarmRepository.cs b/Admin.Core.Repository/Repository_New/Pmt_AlarmRepository.cs new file mode 100644 index 0000000..6b1a5e2 --- /dev/null +++ b/Admin.Core.Repository/Repository_New/Pmt_AlarmRepository.cs @@ -0,0 +1,15 @@ +using Admin.Core.IRepository; +using Admin.Core.Model; + +namespace Admin.Core.Repository +{ + /// + /// Pmt_AlarmRepository + /// + public class Pmt_AlarmRepository : BaseRepository, IPmt_AlarmRepository + { + public Pmt_AlarmRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/Admin.Core.Service/Service_New/Hw_WarehouseServices.cs b/Admin.Core.Service/Service_New/Hw_WarehouseServices.cs index 48373d3..414ca71 100644 --- a/Admin.Core.Service/Service_New/Hw_WarehouseServices.cs +++ b/Admin.Core.Service/Service_New/Hw_WarehouseServices.cs @@ -7,6 +7,7 @@ using System; using Admin.Core.Model.ViewModels; using log4net; using System.Collections.Generic; +using Microsoft.Data.SqlClient; using Admin.Core.PlcServer; namespace Admin.Core.Service @@ -21,8 +22,12 @@ namespace Admin.Core.Service private readonly IHw_BarrelRepository _barrel; private readonly Ixl_materialRepository _materialRepository; private readonly Ixl_recipeRepository _recipeRepository; + private readonly ILR_weighRepository _lrWeighRepository; - public Hw_WarehouseServices(IBaseRepository dal, IHw_WarehouseRepository wareHouse, IHw_WareHouse_SubRepository wareHouse_Sub, IHw_FeedReportRepository feed, IHw_BarrelRepository barrel, Ixl_materialRepository materialRepository, Ixl_recipeRepository recipeRepository) + public Hw_WarehouseServices(IBaseRepository dal, IHw_WarehouseRepository wareHouse, + IHw_WareHouse_SubRepository wareHouse_Sub, IHw_FeedReportRepository feed, + IHw_BarrelRepository barrel, Ixl_materialRepository materialRepository, + Ixl_recipeRepository recipeRepository, ILR_weighRepository lrWeighRepository) { this._dal = dal; base.BaseDal = dal; @@ -32,31 +37,84 @@ namespace Admin.Core.Service _barrel = barrel; _materialRepository = materialRepository; _recipeRepository = recipeRepository; + _lrWeighRepository = lrWeighRepository; } - #region 扫描桶二维码,获取绑定的小料配方 + #region 扫描桶二维码,获取绑定的小料配方物料 /// /// 扫描桶二维码,获取绑定的小料配方 /// /// 桶条码 /// /// - public async Task GetXlInfo(string code) + public async Task GetXlInfo(string kettleBarCode, string planId, string code) { + List list = new List(); + List materList = new List(); try { - Hw_Barrel hw = (await _barrel.QueryAsync(d => d.IsEnable == "是")).FirstOrDefault(d => d.BarCode == code); + Hw_Barrel hw = await _barrel.FirstAsync(d => d.IsEnable == "是" && d.BarCode == code); if (hw == null) { return null; } - var recipe = (await _recipeRepository.QueryAsync(d => d.Recipe_Verify == 1)).FirstOrDefault(d => d.Recipe_Code == hw.MaterialID); + var recipe = await _recipeRepository.FirstAsync(d => d.Recipe_Verify == 1 && d.Recipe_Code == hw.MaterialID); + if (recipe == null) { return null; } + var materialList = await _lrWeighRepository.QueryAsync(d => d.Plan_ID == hw.PlanId && d.Recipe_ID == recipe.ID); + if (materialList.Count() == 0) { return null; } + + foreach (var material in materialList) + { + MaterialView childView = new MaterialView(); + childView.MaterialID = material.Material_ID; + var mat = await _materialRepository.FirstAsync(d => d.ID.Equals(material.Material_ID)); + if (materialList == null) { continue; } + childView.MaterialBarCode = mat.Material_code; + childView.MaterialName = material.Material_Name; + childView.Weight = material.Real_Weight; + childView.Error = material.Real_Error; + childView.MatchOrNot = 0; + list.Add(childView); + } + var kettle = await _dal.FirstAsync(d => d.BarCode.Equals(kettleBarCode)); + var subList = await _wareHouse_Sub.QueryAsync(d => d.MainId == kettle.ID && d.PId.Equals(planId) &&d.MaterialType.Contains("尾料")); + foreach (var check in list) + { + MaterialView childView = new MaterialView(); + childView.MaterialID = check.MaterialID; + var mat = await _materialRepository.FirstAsync(d => d.ID.Equals(check.MaterialID)); + childView.MaterialBarCode = mat.Material_code; + childView.MaterialName = check.MaterialName; + var pList = subList.Where(d => d.Material_Code.Equals(check.MaterialBarCode)); + if (pList == null) + { + childView.MatchOrNot = 0; + materList.Add(childView); + continue; + } + foreach (var item in pList) + { + decimal? maxValue = item.SetWeight + item.SetError; + decimal? minValue = item.SetWeight - item.SetError; + if (minValue <= check.Weight && check.Weight <= maxValue) + { + childView.Weight = check.Weight; + childView.Error = check.Error; + childView.MatchOrNot = 1; + } + else + { + childView.Weight = check.Weight; + childView.Error = check.Error; + childView.MatchOrNot = 0; + } + } + materList.Add(childView); + } BarrelView view = new BarrelView() { BarrelID = hw.BarrelID, BarrelName = hw.BarrelName, BarCode = hw.BarCode, - MaterialID = recipe.Recipe_Code, - MaterialName = recipe.Recipe_Name, - Weight = hw.Weight + child = materList }; return view; } @@ -68,31 +126,46 @@ namespace Admin.Core.Service } #endregion - #region 根据传入的code 查询投料釜下所有的物料 + #region 根据传入的二维码、计划Id 查询反应釜下所有的物料 /// - /// 根据传入的code 查询投料釜下所有的物料 + /// 根据传入的二维码、计划Id 查询反应釜下所有的物料 /// - /// + /// 反应釜二维码 + /// 计划Id /// public async Task QueryByCode(string code, string planId) { + List list = new List(); try { Hw_Warehouse wh = await _wareHouse.FirstAsync(d => d.BarCode == code); if (wh == null) return null; - var sub = await _wareHouse_Sub.QueryAsync(d => d.MainId == wh.ID&& d.PId== planId); - if (sub == null) return null; - - WarehouseView warehouseView = new WarehouseView() + var sub = await _wareHouse_Sub.QueryAsync(d => d.MainId == wh.ID&& d.PId== planId&&(d.MaterialType.Contains("整包")|| d.MaterialType.Contains("尾料"))); + if (sub.Count == 0) return null; + sub.ForEach(sub => + { + HwWareHouseSubView view = new HwWareHouseSubView(); + view.ID = sub.ID; + view.MainId = sub.MainId; + view.PId = sub.PId; + view.ProductName = sub.ProductName; + view.MaterialID = sub.MaterialID; + view.Material_Code = sub.Material_Code; + view.MaterialName = sub.MaterialName; + view.BinId = sub.BinId; + view.MaterialType = sub.MaterialType; + view.SetWeight = sub.SetWeight; + view.SetError = sub.SetError; + list.Add(view); + }); + WarehouseView warehouseView = new WarehouseView() { ID = wh.ID, - PlanId = wh.PlanId, Name = wh.Name, BarCode = wh.BarCode, - CreateTime = wh.CreateTime, - UpdateTime = wh.UpdateTime, - Children = sub - }; + Children = list + }; + return warehouseView; } catch (Exception ex) @@ -112,10 +185,8 @@ namespace Admin.Core.Service public async Task UpdatePlcState(KettleView view) { List subList = null; - List hbList = null; - Hw_WareHouse_Sub sub = null; + List report = new List(); Hw_Warehouse wh = null; - Hw_Barrel hwBarrel = null; string message = string.Empty; string name = string.Empty; @@ -175,20 +246,18 @@ namespace Admin.Core.Service try { - var solventPlc = PlcHelper.siemensList.SingleOrDefault(d=>d.EquipName.Equals("小料PLC")); + //log.Info("开始"); + var solventPlc = PlcHelper.siemensList.SingleOrDefault(d => d.EquipName.Equals("溶剂PLC")); + log.Info($"PLC状态:{solventPlc.plc.IsConnected}"); if (solventPlc.plc.IsConnected) { + #region 记录数据 //同时记录该扫码到数据库中 - List list = await _wareHouse.QueryAsync(); - if (list != null) - { - wh = list.FirstOrDefault(d => d.BarCode == view.KCode); - subList = await _wareHouse_Sub.QueryAsync(d => d.MainId == wh.ID); - if (subList.Count > 0) - { - sub = subList.FirstOrDefault(d => d.MaterialID == view.MatCode.Trim()); - } - } + wh = await _wareHouse.FirstAsync(d => d.BarCode == view.KCode); + if (wh == null) return false; + subList = await _wareHouse_Sub.QueryAsync(d => d.MainId == wh.ID); + if (subList.Count == 0) return false; + log.Info("开启模式"); if (view.State == 1) { message = "开启"; @@ -202,49 +271,37 @@ namespace Admin.Core.Service log.Error("传递状态为空!"); return false; } - - Hw_FeedReport hw = new Hw_FeedReport() + foreach (var item in view.Child) { - WID = wh.ID, - PlanId = view.PlanId, - WName = wh.Name, - WCode = wh.BarCode, - MaterialId = sub.MaterialID, - MaterialName = sub.MaterialName, - MCode = sub.Material_Code, - MType = view.MatType, - IsTrue = message, - CreateTime = DateTime.Now, - WholePackage = view.WholePackage.Trim() - }; - - //解绑 桶绑定 - //hbList = await _barrel.QueryAsync(); - //if (hbList != null) - //{ - // hwBarrel = hbList.FirstOrDefault(d => d.BarCode == view.BarrelCode); - // if (hwBarrel != null) - // { - // hwBarrel.MaterialID = null; - // hwBarrel.MaterialName = null; - // await _feed.UpdateAsync(hw); - // } - //} + Hw_FeedReport hw = new Hw_FeedReport() + { + WID = wh.ID, + PlanId = view.PlanId, + WName = wh.Name, + WCode = wh.BarCode, + MaterialId = item.MatCode, + MaterialName = item.MatName, + MCode = item.MatCode, + MType = item.MatType, + IsTrue = message, + CreateTime = DateTime.Now, + WholePackage = item.WholePackage.Trim() + }; + report.Add(hw); + } + await _feed.AddAsync(report); - //保存记录 - // int i = await _feed.AddAsync(hw); if (string.IsNullOrEmpty(name)) { log.Error("点位名称为空!"); return false; } - bool result = solventPlc.plc.WriteInt16(name, view.State.ToString());//反应釜点位 if (result) { if (view.State == 1) { - await _feed.AddAsync(hw); + await _feed.AddAsync(report); } return result; } @@ -253,11 +310,16 @@ namespace Admin.Core.Service log.Error("写入点位失败!"); return result; } + #endregion + } + else + { + return false; } - return false; } catch (Exception ex) { + log.Info("异常:"+ex.Message); log.Error(ex.Message); return false; } @@ -271,7 +333,8 @@ namespace Admin.Core.Service /// public async Task> GetWarehousePlan(string code) { - Hw_Warehouse wh = await _wareHouse.FirstAsync(d=>d.BarCode== code); + + Hw_Warehouse wh = await _wareHouse.FirstAsync(d=>d.BarCode== code.Trim()); if (wh==null) return null; var list = await _wareHouse_Sub.QueryAsync(d=>d.MainId== wh.ID); var planList = (from d in list diff --git a/Admin.Core.Service/Service_New/LR_AlarmlogServices.cs b/Admin.Core.Service/Service_New/LR_AlarmlogServices.cs new file mode 100644 index 0000000..588e47b --- /dev/null +++ b/Admin.Core.Service/Service_New/LR_AlarmlogServices.cs @@ -0,0 +1,17 @@ +using Admin.Core.IRepository; +using Admin.Core.Service; +using Admin.Core.IService; +using Admin.Core.Model; + +namespace Admin.Core.Service +{ + public class LR_AlarmlogServices : BaseServices, ILR_AlarmlogServices + { + private readonly IBaseRepository _dal; + public LR_AlarmlogServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + } +} \ No newline at end of file diff --git a/Admin.Core.Service/Service_New/LR_weighServices.cs b/Admin.Core.Service/Service_New/LR_weighServices.cs new file mode 100644 index 0000000..62767e6 --- /dev/null +++ b/Admin.Core.Service/Service_New/LR_weighServices.cs @@ -0,0 +1,17 @@ +using Admin.Core.IRepository; +using Admin.Core.Service; +using Admin.Core.IService; +using Admin.Core.Model; + +namespace Admin.Core.Service +{ + public class LR_weighServices : BaseServices, ILR_weighServices + { + private readonly IBaseRepository _dal; + public LR_weighServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + } +} \ No newline at end of file diff --git a/Admin.Core.Service/Service_New/Pmt_AlarmServices.cs b/Admin.Core.Service/Service_New/Pmt_AlarmServices.cs new file mode 100644 index 0000000..bf6735f --- /dev/null +++ b/Admin.Core.Service/Service_New/Pmt_AlarmServices.cs @@ -0,0 +1,17 @@ +using Admin.Core.IRepository; +using Admin.Core.Service; +using Admin.Core.IService; +using Admin.Core.Model; + +namespace Admin.Core.Service +{ + public class Pmt_AlarmServices : BaseServices, IPmt_AlarmServices + { + private readonly IBaseRepository _dal; + public Pmt_AlarmServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + } +} \ No newline at end of file diff --git a/Admin.Core.Service/Service_New/SolventServices.cs b/Admin.Core.Service/Service_New/SolventServices.cs index 74abe28..159fa0b 100644 --- a/Admin.Core.Service/Service_New/SolventServices.cs +++ b/Admin.Core.Service/Service_New/SolventServices.cs @@ -7,6 +7,8 @@ using System.Linq; using System.Collections.Generic; using log4net; using Admin.Core.PlcServer; +using System; +using NPOI.SS.Formula.Functions; namespace Admin.Core.Service { @@ -56,15 +58,20 @@ namespace Admin.Core.Service { if (view.Weighbridge == "1号地磅") { - bool matCode = plcList.plc.WriteInt16("DB110.DBW400.0", "1");//执行启动 - - if (matCode) + int rate = Convert.ToInt32(view.Rate * 100); + bool rr=plcList.plc.WriteInt16("DB110.DBW10.0", rate.ToString());//传入固率 + bool barCode = plcList.plc.WriteInt16("DB110.DBW1768.0", "1"); + // bool matCode = plcList.plc.WriteInt16("DB110.DBW482.0", "1");//执行启动 + + if (barCode) { - plcList.plc.Writedouble("DB110.DBW443.0", view.Rate);//传入固率 + + //log.Info(view.Rate + "&" + rate); + Hw_SolventErrorPreventionReport report = new Hw_SolventErrorPreventionReport() { PlanId = view.Plan_Id, - FinishedNum = plcList.plc.ReadInt16("DB110.DBW2") + 1, + FinishedNum = plcList.plc.ReadInt16("DB110.DBW1758.0"), RMatCode = view.RMatCode, MaterialID = view.MaterialID, MaterialName = view.MaterialName, @@ -76,26 +83,27 @@ namespace Admin.Core.Service if (rtPlanList.Count > 0) { var rtPlan = rtPlanList.FirstOrDefault(d => d.Plan_Id == view.Plan_Id); - - if (plcList.plc.ReadInt16("DB110.DBW402") != 250) + + if (plcList.plc.ReadInt16("DB110.DBW8") != 250) { - var hwWeighList = await _hwWeighRepository.GetWaiteMaterial(view.Plan_Id); - if (hwWeighList != null) - { - if (hwWeighList.Count() > (rtPlan.Exec_Num + 1)) - { - rtPlan.Exec_Num = 1; - } - else if (hwWeighList.Count() == (rtPlan.Exec_Num + 1)) - { - rtPlan.Exec_Num = rtPlan.Exec_Num + 1; - } - else - { - rtPlan.Exec_Num = 1; - } - } - + //var hwWeighList = await _hwWeighRepository.GetWaiteMaterial(view.Plan_Id); + //if (hwWeighList != null) + //{ + + // if (hwWeighList.Count() > (rtPlan.Exec_Num + 1)) + // { + // rtPlan.Exec_Num = 1; + // } + // else if (hwWeighList.Count() == (rtPlan.Exec_Num + 1)) + // { + // rtPlan.Exec_Num = rtPlan.Exec_Num + 1; + // } + // else + // { + // rtPlan.Exec_Num = 1; + // } + //} + rtPlan.Exec_Num = plcList.plc.ReadInt16("DB110.DBW1758.0"); //保存本次数据 int i = await _solventErrorPreventionReportRepository.AddAsync(report); var cylinderList = _hwCylinderRepository.Query(); @@ -111,22 +119,24 @@ namespace Admin.Core.Service return true; } } - + //等待 return false; } return false; } else if (view.Weighbridge == "2号地磅") { - bool matCode = plcList.plc.WriteInt16("DB111.DBW400.0", "1");//执行启动 - - if (matCode) + int rate = Convert.ToInt32(view.Rate * 100); + plcList.plc.WriteInt16("DB110.DBW10.0", rate.ToString());//传入固率 + bool barCode = plcList.plc.WriteInt16("DB110.DBW1768.0", "1"); + // bool matCode = plcList.plc.WriteInt16("DB110.DBW482.0", "1");//执行启动 + + if (barCode) { - plcList.plc.Writedouble("DB111.DBW443.0", view.Rate);//传入固率 Hw_SolventErrorPreventionReport report = new Hw_SolventErrorPreventionReport() { PlanId = view.Plan_Id, - FinishedNum = plcList.plc.ReadInt16("DB111.DBW2") + 1, + FinishedNum = plcList.plc.ReadInt16("DB110.DBW1758.0"), RMatCode = view.RMatCode, MaterialID = view.MaterialID, MaterialName = view.MaterialName, @@ -134,31 +144,31 @@ namespace Admin.Core.Service WholeMaterial = view.WholeMaterial }; - var rtPlanList = await _planRepository.QueryAsync(d => d.Plan_State == 3); if (rtPlanList.Count > 0) { var rtPlan = rtPlanList.FirstOrDefault(d => d.Plan_Id == view.Plan_Id); - - if (plcList.plc.ReadInt16("DB111.DBW402") != 250) + + if (plcList.plc.ReadInt16("DB110.DBW8") != 250) { - var hwWeighList = await _hwWeighRepository.GetWaiteMaterial(view.Plan_Id); - if (hwWeighList != null) - { - if (hwWeighList.Count() > (rtPlan.Exec_Num + 1)) - { - rtPlan.Exec_Num = 1; - } - if (hwWeighList.Count() == (rtPlan.Exec_Num + 1)) - { - rtPlan.Exec_Num = rtPlan.Exec_Num + 1; - } - if (hwWeighList.Count() > (rtPlan.Exec_Num + 1)) - { - rtPlan.Exec_Num = rtPlan.Exec_Num + 1; - } - - } + //var hwWeighList = await _hwWeighRepository.GetWaiteMaterial(view.Plan_Id); + //if (hwWeighList != null) + //{ + + // if (hwWeighList.Count() > (rtPlan.Exec_Num + 1)) + // { + // rtPlan.Exec_Num = 1; + // } + // else if (hwWeighList.Count() == (rtPlan.Exec_Num + 1)) + // { + // rtPlan.Exec_Num = rtPlan.Exec_Num + 1; + // } + // else + // { + // rtPlan.Exec_Num = 1; + // } + //} + rtPlan.Exec_Num = plcList.plc.ReadInt16("DB110.DBW1758.0"); //保存本次数据 int i = await _solventErrorPreventionReportRepository.AddAsync(report); var cylinderList = _hwCylinderRepository.Query(); @@ -166,22 +176,20 @@ namespace Admin.Core.Service { return false; } - rtPlan.CylinderName = cylinderList.FirstOrDefault(d => d.BarCode == view.CylinderBarCode).Name; - rtPlan.CylinderBarCode = view.CylinderBarCode; + Hw_Cylinder hw_Cylinder = cylinderList.FirstOrDefault(d => d.BarCode == view.CylinderBarCode.Trim()); + rtPlan.CylinderName = hw_Cylinder.Name; + rtPlan.CylinderBarCode = hw_Cylinder.BarCode; log.Info(view.CylinderBarCode); await _planRepository.UpdateExecDb(rtPlan);//更新数据库 return true; } } - + //等待 return false; } return false; } - else - { - return false; - } + return false; } else { @@ -346,33 +354,64 @@ namespace Admin.Core.Service var plcList = PlcHelper.siemensList.SingleOrDefault(d => d.EquipName.Equals("溶剂PLC")); if (plcList.plc.IsConnected) { - int endStatus = plcList.plc.ReadInt16("DB110.DBW6.0");//完成信号 - if (endStatus == 1) + if (weighbridge== "1号地磅") { int planNum = plcList.plc.ReadInt16("DB110.DBW2.0");//执行批次 - if (plan.Plan_Num > plan.Real_Num) + if (plan.Plan_Num > planNum) { var rtPlanList = await _planRepository.QueryAsync(d => d.Plan_State == 3); var rtPlan = rtPlanList.FirstOrDefault(d => d.Plan_Id == plan.Plan_Id); execNum = rtPlan.Exec_Num; - - var hwWeigh = hwWeighList.FirstOrDefault(d => d.MID == execNum); + int materialNo = plcList.plc.ReadInt16("DB110.DBW1758");//当前执行物料 + if (materialNo == 0) materialNo = 1; + var hwWeigh = hwWeighList.FirstOrDefault(d => d.MID == materialNo); if (hwWeigh == null) return null; return hwWeigh; } + else + { + //var rtPlanList = await _planRepository.QueryAsync(d => d.Plan_State == 3); + //var rtPlan = rtPlanList.FirstOrDefault(d => d.Plan_Id == plan.Plan_Id); + //execNum = rtPlan.Exec_Num; + //int materialNo = plcList.plc.ReadInt16("DB110.DBW478.0");//当前执行物料 + //var hwWeigh = hwWeighList.FirstOrDefault(d => d.MID == materialNo); + //if (hwWeigh == null) return null; + + return null; + } } else { - var rtPlanList = await _planRepository.QueryAsync(d => d.Plan_State == 3); - var rtPlan = rtPlanList.FirstOrDefault(d => d.Plan_Id == plan.Plan_Id); - execNum = rtPlan.Exec_Num; - - var hwWeigh = hwWeighList.FirstOrDefault(d => d.MID == execNum); - if (hwWeigh == null) return null; + int planNum = plcList.plc.ReadInt16("DB110.DBW2.0");//执行批次 + if (plan.Plan_Num > planNum) + { + var rtPlanList = await _planRepository.QueryAsync(d => d.Plan_State == 3); + var rtPlan = rtPlanList.FirstOrDefault(d => d.Plan_Id == plan.Plan_Id); + execNum = rtPlan.Exec_Num; + int materialNo = plcList.plc.ReadInt16("DB110.DBW1758");//当前执行物料 + var hwWeigh = hwWeighList.FirstOrDefault(d => d.MID == materialNo); + if (hwWeigh == null) return null; - return hwWeigh; + return hwWeigh; + } + else + { + //var rtPlanList = await _planRepository.QueryAsync(d => d.Plan_State == 3); + //var rtPlan = rtPlanList.FirstOrDefault(d => d.Plan_Id == plan.Plan_Id); + //execNum = rtPlan.Exec_Num; + //int materialNo = plcList.plc.ReadInt16("DB110.DBW478.0");//当前执行物料 + //var hwWeigh = hwWeighList.FirstOrDefault(d => d.MID == materialNo); + //if (hwWeigh == null) return null; + + return null; + } } + + } + else + { + log.Error("PLC连接失败!"); } return null; } diff --git a/Admin.Core.Service/Service_New/xl_materialServices.cs b/Admin.Core.Service/Service_New/xl_materialServices.cs index f6538e4..5ea3582 100644 --- a/Admin.Core.Service/Service_New/xl_materialServices.cs +++ b/Admin.Core.Service/Service_New/xl_materialServices.cs @@ -306,14 +306,10 @@ namespace Admin.Core.Service var plcList = PlcHelper.siemensList.SingleOrDefault(d => d.EquipName.Equals("小料PLC")); if (plcList.plc.IsConnected)// 000533 { - //int tt123 = plcList.plc.ReadInt16("DB110.DBW88").ObjToInt(); - //int tt = plcList.plc.ReadInt16("DB110.DBW90").ObjToInt(); - //int tt2 = plcList.plc.ReadInt32("DB110.DBW90").ObjToInt(); - //int yyy = plcList.plc.ReadInt16("DB110.DBW90").ObjToInt(); if (plcList.plc.ReadInt16("DB110.DBW90").ObjToInt() == 1)//1:检量秤准备好 { - decimal tcheckWeight = Convert.ToDecimal(plcList.plc.ReadInt16("DB104.DBW164")) / 100;//检量秤重量 - //log.Info($"重量:{tcheckWeight}"); + decimal tcheckWeight = Convert.ToDecimal(plcList.plc.ReadInt16("DB104.DBW164")) / 1000;//检量秤重量 + log.Info($"重量:{tcheckWeight}"); //绑定桶 var barrelList = await _hw_BarrelRepository.QueryAsync(); @@ -348,7 +344,6 @@ namespace Admin.Core.Service decimal totalMaxError = exec.Total_Weight + exec.Total_Error;//最大值 decimal totalMinError = exec.Total_Weight - exec.Total_Error;//最小值 - if (totalMinError <= tcheckWeight && tcheckWeight <= totalMaxError)//在误差之内 { await _hw_BarrelRepository.UpdateAsync(barrel); @@ -359,11 +354,11 @@ namespace Admin.Core.Service log.Info($"no1>>剩余批次:{batch}>计划批次:{exec.Plan_Num}》当前批次》{tcheckBatch}"); await _hw_BarrelRepository.UpdateAsync(barrel); var r = await UpdatePlanCompletedQuantity(plcList, exec.Plan_Id, tcheckBatch, 8, DateTime.Now, total_Weight, total_Error); - log.Info("称量完成:" + r); + //log.Info("称量完成:" + r); if (r) { //判断上位机判断当前值与配方总重,满足要求时,置“2” - plcList.plc.WriteInt32("DB110.DBW88", 2);//2:上位机完成 + plcList.plc.WriteInt32("DB110.DBW88", 2);//2:上位机完成,实点位为DB110.DBW90 return 6; } else @@ -376,7 +371,7 @@ namespace Admin.Core.Service log.Info($"no2>>剩余批次:{batch}>计划批次:{exec.Plan_Num}》当前批次》{tcheckBatch}"); await _hw_BarrelRepository.UpdateAsync(barrel); var r = await UpdatePlanCompletedQuantity(exec.Plan_Id, tcheckBatch, total_Weight, total_Error); - log.Info("称量未完成:" + r); + //log.Info("称量未完成:" + r); if (r) { //判断上位机判断当前值与配方总重,满足要求时,置“2” @@ -601,7 +596,16 @@ namespace Admin.Core.Service //} while (tb > 0); log.Info("获取批次:" + tb); return tb; - } + } + #endregion + + #region 获取当前正在称量的物料 + public Task GetCurrentMaterial() + { + //down = await _planRepository.GetDownLoadPlan(); + //if (down.Count() == 0) { return 0; } + return Task.CompletedTask; + } #endregion } } \ No newline at end of file diff --git a/Admin.Core.Tasks/QuartzNet/Jobs/Job_Admin_Quartz.cs b/Admin.Core.Tasks/QuartzNet/Jobs/Job_Admin_Quartz.cs index 36823e4..6528018 100644 --- a/Admin.Core.Tasks/QuartzNet/Jobs/Job_Admin_Quartz.cs +++ b/Admin.Core.Tasks/QuartzNet/Jobs/Job_Admin_Quartz.cs @@ -1,8 +1,13 @@ using Admin.Core.Common; +using Admin.Core.IService; using Admin.Core.IService.ISys; +using Admin.Core.Model; +using Admin.Core.PlcServer; +using Admin.Core.Service; using Quartz; -using S71500.Impl; using System; +using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; /// @@ -12,22 +17,83 @@ namespace Admin.Core.Tasks { public class Job_Admin_Quartz : JobBase, IJob { - string address = Appsettings.app("Siemens", "ConString").ToString(); - int port = Appsettings.app("Siemens", "Port").ObjToInt(); - - public Job_Admin_Quartz(ISysTasksQzService SysTasksQzService, ISysJobLogService sysJobLogService) + private readonly IPmt_AlarmServices _pmtAlarmServices; + private readonly ILR_AlarmlogServices _lrAlarmlogServices; + + public Job_Admin_Quartz(ISysTasksQzService SysTasksQzService, ISysJobLogService sysJobLogService, + IPmt_AlarmServices pmtAlarmServices, ILR_AlarmlogServices lrAlarmlogServices) { _SysTasksQzService = SysTasksQzService; _sysJobLogService = sysJobLogService; + _pmtAlarmServices = pmtAlarmServices; + _lrAlarmlogServices = lrAlarmlogServices; } public async Task Execute(IJobExecutionContext context) { await ExecuteJob(context, async () => await Run(context)); } - public Task Run(IJobExecutionContext context) - { - - return Task.CompletedTask; + + public async Task Run(IJobExecutionContext context) + { + var plcList = PlcHelper.siemensList.SingleOrDefault(d => d.EquipName.Equals("小料PLC")); + if (plcList.plc.IsConnected) + { + List addAlarmList = new List(); + List updateAlarmList = new List(); + List list = await _pmtAlarmServices.QueryAsync(); + + foreach (var item in list) + { + if (plcList.plc.ReadBool(item.Alarm_Point)) + { + var alarm = await _lrAlarmlogServices.FirstAsync(d => d.Alarm_ID == item.Alarm_ID); + if (alarm==null) + { + LR_Alarmlog lR_Alarmlog = new LR_Alarmlog(); + + lR_Alarmlog.Equip_Code = "01"; + lR_Alarmlog.Alarm_ID = item.Alarm_ID; + lR_Alarmlog.Alarm_OccurTime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); + lR_Alarmlog.Alarm_Status = 1; + lR_Alarmlog.Alarm_GUID = "01"; + + await _lrAlarmlogServices.AddAsync(lR_Alarmlog); + //addAlarmList.Add(lR_Alarmlog); + } + else + { + alarm.Alarm_ClearTime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); + alarm.Alarm_Status = 1; + await _lrAlarmlogServices.UpdateAsync(alarm); + } + } + else + { + var alarm = await _lrAlarmlogServices.FirstAsync(d => d.Alarm_ID == item.Alarm_ID); + if (alarm == null) + { + LR_Alarmlog lR_Alarmlog = new LR_Alarmlog(); + + lR_Alarmlog.Equip_Code = "01"; + lR_Alarmlog.Alarm_ID = item.Alarm_ID; + lR_Alarmlog.Alarm_OccurTime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); + lR_Alarmlog.Alarm_Status = 0; + lR_Alarmlog.Alarm_GUID = "01"; + + await _lrAlarmlogServices.UpdateAsync(lR_Alarmlog); + } + else + { + alarm.Alarm_ClearTime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); + alarm.Alarm_Status = 0; + + await _lrAlarmlogServices.UpdateAsync(alarm); + } + } + } + + + } } } } diff --git a/README (2).md b/README (2).md deleted file mode 100644 index 10f23c0..0000000 --- a/README (2).md +++ /dev/null @@ -1,18 +0,0 @@ -# Admin.Core -基于.net6 创建的一个公共的后端框架,目前包含 webpApi、WPF、控制台 -#### 软件架构 -软件架构说明 - - -#### 安装教程 - -1. 安装.net6 开发环境 -2. web部署:配置IIS -3. WPF开发、控制台:需要app.cs中 将创建的服务、仓储依赖注入 - -#### 使用说明 - -1. xxxx -2. xxxx -3. xxxx -