From 0537ee5434c0fc10b1e9c5adc5281d1e66cd99f2 Mon Sep 17 00:00:00 2001 From: SoulStar Date: Fri, 6 Dec 2024 14:50:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Admin.Core.Api/Admin.Core.Api.xml | 9 +- Admin.Core.Api/Admin.Core.Model.xml | 75 ++++++++ .../Business/WarehouseController.cs | 71 ++++--- Admin.Core.Api/PLTBusiness/HttpService.cs | 12 +- Admin.Core.Api/PLTBusiness/XlBusiness.cs | 2 +- .../IService_New/IBinFeedingReportServices.cs | 1 + .../Model_New/BinFeedingReport.cs | 178 +++++++++--------- .../Model_New/LR_weigh_BatchCode.cs | 16 ++ .../ViewModels/MesDownLoadPlanList.cs | 56 ++++++ .../Service_New/BinFeedingReportServices.cs | 25 +++ .../Service_New/Hw_BarrelServices.cs | 8 +- .../Service_New/Hw_WarehouseServices.cs | 10 +- 12 files changed, 331 insertions(+), 132 deletions(-) create mode 100644 Admin.Core.Model/Model_New/LR_weigh_BatchCode.cs diff --git a/Admin.Core.Api/Admin.Core.Api.xml b/Admin.Core.Api/Admin.Core.Api.xml index a52ca7a..fa457cb 100644 --- a/Admin.Core.Api/Admin.Core.Api.xml +++ b/Admin.Core.Api/Admin.Core.Api.xml @@ -405,7 +405,12 @@ 称重服务类 - + + + 料仓投料验证服务类 + + + 构造方法 @@ -470,7 +475,7 @@ 根据罐号查询称量列表 - + diff --git a/Admin.Core.Api/Admin.Core.Model.xml b/Admin.Core.Api/Admin.Core.Model.xml index 1789e3d..9b4d0ca 100644 --- a/Admin.Core.Api/Admin.Core.Model.xml +++ b/Admin.Core.Api/Admin.Core.Model.xml @@ -4619,6 +4619,81 @@ 产品名称 + + + 物料所属料仓 + + + + + 物料编码二维码 + + + + + 物料名称 + + + + + 物料类型:整包、尾料、溶剂 + + + + + 重量 + + + + + 误差值 + + + + + 工装区分,相同值代表在一个料桶中 + + + + + 是否有固含 1为有,0没有 + + + + + 固含率 + + + + + 泵条码 + + + + + 地磅 + + + + + 配方号 + + + + + 备注 + + + + + 皮重 + + + + + 反应釜编号 + + 拉缸、泵查询参数 diff --git a/Admin.Core.Api/Controllers/Business/WarehouseController.cs b/Admin.Core.Api/Controllers/Business/WarehouseController.cs index 7d2432f..413a113 100644 --- a/Admin.Core.Api/Controllers/Business/WarehouseController.cs +++ b/Admin.Core.Api/Controllers/Business/WarehouseController.cs @@ -18,6 +18,7 @@ using NPOI.SS.Formula.Functions; using TouchSocket.Core; using System.Numerics; using Admin.Core.IService.IService_New; +using Admin.Core.Model.Model_New; namespace Admin.Core.Api.Controllers.Business { @@ -51,6 +52,11 @@ namespace Admin.Core.Api.Controllers.Business /// private readonly ILR_weighServices _lr_weighService; + /// + /// 料仓投料验证服务类 + /// + private readonly IBinFeedingReportServices _binFeedingReportServices; + #region 构造方法 /// /// 构造方法 @@ -59,12 +65,13 @@ namespace Admin.Core.Api.Controllers.Business /// /// /// - public WarehouseController(IHw_WarehouseServices hw_WarehouseServices, ISysUserService sysUserService, IHw_BarrelServices hwBarrelService, ILR_weighServices lrweighService) : base(sysUserService) + public WarehouseController(IHw_WarehouseServices hw_WarehouseServices, ISysUserService sysUserService, IHw_BarrelServices hwBarrelService, ILR_weighServices lrweighService, IBinFeedingReportServices binFeedingReportServices) : base(sysUserService) { _sysUserService = sysUserService; _hw_WarehouseService = hw_WarehouseServices; _hw_BarrelService = hwBarrelService; _lr_weighService = lrweighService; + _binFeedingReportServices = binFeedingReportServices; } #endregion @@ -162,30 +169,30 @@ namespace Admin.Core.Api.Controllers.Business if (result1.Contains("成功")) - { - if (result2.Contains("成功")) - { - if (result3.Contains("成功")) - { - return Success(true); + { + if (result2.Contains("成功")) + { + if (result3.Contains("成功")) + { + return Success(true); } - else - { - return Failed(result3 + "执行失败!"); + else + { + return Failed(result3 + "执行失败!"); } - } - else - { - return Failed(result2 + "执行失败!"); } - } - else - { - return Failed(result1 + "执行失败!"); + else + { + return Failed(result2 + "执行失败!"); + } + } + else + { + return Failed(result1 + "执行失败!"); } - ////配方名或配方编号 + ////配方名或配方编号 //string ss1 = "a82d016e813c4ac3bca0244c519da591"; ////批次号 //string ss2 = "2408090522"; @@ -198,7 +205,7 @@ namespace Admin.Core.Api.Controllers.Business { return Failed(ex.Message + "执行失败!"); } - return Failed("执行失败!"); + return Failed("执行失败!"); } @@ -270,27 +277,39 @@ namespace Admin.Core.Api.Controllers.Business /// /// 根据罐号查询称量列表 /// - /// + /// /// [HttpGet] - public async Task>> GetWeightInfoByBarrelID(string barrelBarcode) + public async Task>> GetWeightInfoByBarrelID(string barrelBarcode) { if (!barrelBarcode.IsNotEmptyOrNull()) { - return Failed>("传入参数为空!"); + return Failed>("传入参数为空!"); } MessageModel> messageModel = new MessageModel>(); string planID = _hw_BarrelService.GetPlanIdByBarrelID(barrelBarcode.Trim()); if (string.IsNullOrEmpty(planID)) { - return Failed>("查询不到罐号对应的计划ID!"); + return Failed>("查询不到罐号对应的计划ID!"); + } + if (planID == "-1") + { + return Failed>("查询不到罐号!"); + } + List wlist = _lr_weighService.GetRecentWeightList(planID); + List list = new List(); + foreach (LR_weigh weigh in wlist) + { + LR_weigh_BatchCode record = new LR_weigh_BatchCode(); + record.WeightData = weigh; + record.BatchCode = _binFeedingReportServices.GetBatchNumberByMaterialAndBinID(weigh.Material_ID, weigh.Bin_Serial ?? -1); + list.Add(record); } - List list = _lr_weighService.GetRecentWeightList(planID); if (list != null) { return Success(list); } - return Failed>("执行失败!"); + return Failed>("执行失败!"); } } diff --git a/Admin.Core.Api/PLTBusiness/HttpService.cs b/Admin.Core.Api/PLTBusiness/HttpService.cs index 50df55a..c24e6f3 100644 --- a/Admin.Core.Api/PLTBusiness/HttpService.cs +++ b/Admin.Core.Api/PLTBusiness/HttpService.cs @@ -61,7 +61,7 @@ namespace Admin.Core.Api.PLTBusiness //执行任务 //log.Info($"{DateTime.Now}"); - if (_tokenExpirationTime == 0) + if (_tokenExpirationTime <= 0) { if (await GetToken()) { @@ -122,7 +122,7 @@ namespace Admin.Core.Api.PLTBusiness { {"pageIndex", 200}, {"pageSize", 0}, - {"orgCode", "Mesnac"}, + {"orgCode", "01"}, }; try { @@ -174,7 +174,7 @@ namespace Admin.Core.Api.PLTBusiness { {"pageIndex", 200}, {"pageSize", 0}, - {"orgCode", "Mesnac"}, + {"orgCode", "01"}, }; try { @@ -222,9 +222,9 @@ namespace Admin.Core.Api.PLTBusiness { Dictionary _tokenDictionary = new Dictionary() { - {"authCode", "QT_XXX"}, - {"appid", "q7cloud_XXX"}, - {"secret", "f434eab8b9652524dc719e33f4ff255a45570XXX"} + {"authCode", "QT_U9C"}, + {"appid", "q7cloud_e68b20"}, + {"secret", "f5137d6b53968fcbb95948f00cfce81bd8400ffa"} }; try diff --git a/Admin.Core.Api/PLTBusiness/XlBusiness.cs b/Admin.Core.Api/PLTBusiness/XlBusiness.cs index 67ef605..c19701a 100644 --- a/Admin.Core.Api/PLTBusiness/XlBusiness.cs +++ b/Admin.Core.Api/PLTBusiness/XlBusiness.cs @@ -38,7 +38,7 @@ namespace Admin.Core.Api.PLTBusiness foreach (var mesMaterial in list) { // Step 3: 在B表中查询是否存在相同ID的记录 - var material = await _xl_materialService.SelectXlMaterialById(mesMaterial.id.ToString()); + xl_material material = await _xl_materialService.SelectXlMaterialById(mesMaterial.id.ToString()); if (material == null) { diff --git a/Admin.Core.IService/IService_New/IBinFeedingReportServices.cs b/Admin.Core.IService/IService_New/IBinFeedingReportServices.cs index f6a617a..342c332 100644 --- a/Admin.Core.IService/IService_New/IBinFeedingReportServices.cs +++ b/Admin.Core.IService/IService_New/IBinFeedingReportServices.cs @@ -8,5 +8,6 @@ namespace Admin.Core.IService /// public interface IBinFeedingReportServices :IBaseServices { + string GetBatchNumberByMaterialAndBinID(string materialID, int binID); } } \ No newline at end of file diff --git a/Admin.Core.Model/Model_New/BinFeedingReport.cs b/Admin.Core.Model/Model_New/BinFeedingReport.cs index da0b3f7..f2413f2 100644 --- a/Admin.Core.Model/Model_New/BinFeedingReport.cs +++ b/Admin.Core.Model/Model_New/BinFeedingReport.cs @@ -9,96 +9,96 @@ namespace Admin.Core.Model /// /// /// - [SugarTable( "BinFeedingReport", "admin_sqlite")] + [SugarTable("Hw_BinTypeErrorPreventionReport", "admin_sqlite")] public class BinFeedingReport { - public BinFeedingReport() - { - } - /// - /// Desc: - /// Default: - /// Nullable:False - /// - [SugarColumn(IsPrimaryKey=true,IsIdentity=true)] -public int ID { get; set; } - /// - /// Desc:料仓主键 - /// Default: - /// Nullable:True - /// -public int? BinID { get; set; } - /// - /// Desc:名称 - /// Default: - /// Nullable:True - /// -public string Bin_Name { get; set; } - /// - /// Desc:条码 - /// Default: - /// Nullable:True - /// -public string Bin_Code { get; set; } - /// - /// Desc:批次 - /// Default: - /// Nullable:True - /// -public string Batch { get; set; } - /// - /// Desc:名称 - /// Default: - /// Nullable:True - /// -public string ProductName { get; set; } - /// - /// Desc:物料ID - /// Default: - /// Nullable:True - /// -public string MaterialID { get; set; } - /// - /// Desc:物料名称 - /// Default: - /// Nullable:True - /// -public string MaterialName { get; set; } - /// - /// Desc:条码 - /// Default: - /// Nullable:True - /// -public string Material_Code { get; set; } - /// - /// Desc:存货编码 - /// Default: - /// Nullable:True - /// -public string Material_InventoryCode { get; set; } - /// - /// Desc:批次号 - /// Default: - /// Nullable:True - /// -public string Material_BatchNumber { get; set; } - /// - /// Desc:流水号 - /// Default: - /// Nullable:True - /// -public string Material_SerialCode { get; set; } - /// - /// Desc:创建时间 - /// Default: - /// Nullable:True - /// -public DateTime? CreateTime { get; set; } - /// - /// Desc:完整二维码 - /// Default: - /// Nullable:True - /// -public string BarCodeStr { get; set; } + public BinFeedingReport() + { + } + /// + /// Desc: + /// Default: + /// Nullable:False + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int ID { get; set; } + /// + /// Desc:料仓主键 + /// Default: + /// Nullable:True + /// + public int? BinID { get; set; } + /// + /// Desc:名称 + /// Default: + /// Nullable:True + /// + public string Bin_Name { get; set; } + /// + /// Desc:条码 + /// Default: + /// Nullable:True + /// + public string Bin_Code { get; set; } + /// + /// Desc:批次 + /// Default: + /// Nullable:True + /// + public string Batch { get; set; } + /// + /// Desc:名称 + /// Default: + /// Nullable:True + /// + public string ProductName { get; set; } + /// + /// Desc:物料ID + /// Default: + /// Nullable:True + /// + public string MaterialID { get; set; } + /// + /// Desc:物料名称 + /// Default: + /// Nullable:True + /// + public string MaterialName { get; set; } + /// + /// Desc:条码 + /// Default: + /// Nullable:True + /// + public string Material_Code { get; set; } + /// + /// Desc:存货编码 + /// Default: + /// Nullable:True + /// + public string Material_InventoryCode { get; set; } + /// + /// Desc:批次号 + /// Default: + /// Nullable:True + /// + public string Material_BatchNumber { get; set; } + /// + /// Desc:流水号 + /// Default: + /// Nullable:True + /// + public string Material_SerialCode { get; set; } + /// + /// Desc:创建时间 + /// Default: + /// Nullable:True + /// + public DateTime? CreateTime { get; set; } + /// + /// Desc:完整二维码 + /// Default: + /// Nullable:True + /// + public string BarCodeStr { get; set; } } } \ No newline at end of file diff --git a/Admin.Core.Model/Model_New/LR_weigh_BatchCode.cs b/Admin.Core.Model/Model_New/LR_weigh_BatchCode.cs new file mode 100644 index 0000000..2f434b5 --- /dev/null +++ b/Admin.Core.Model/Model_New/LR_weigh_BatchCode.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Admin.Core.Model.Model_New +{ + public class LR_weigh_BatchCode + { + + public LR_weigh WeightData { get; set; } + + public string BatchCode { get; set; } + } +} diff --git a/Admin.Core.Model/ViewModels/MesDownLoadPlanList.cs b/Admin.Core.Model/ViewModels/MesDownLoadPlanList.cs index c7a03df..56cc39a 100644 --- a/Admin.Core.Model/ViewModels/MesDownLoadPlanList.cs +++ b/Admin.Core.Model/ViewModels/MesDownLoadPlanList.cs @@ -17,23 +17,79 @@ public class MesDownLoadPlanList /// public string ProductName { get; set; } + /// + /// 物料所属料仓 + /// public string BinId { get; set; } + /// + /// 物料编码二维码 + /// public string Material_Code { get; set; } + + /// + /// 物料名称 + /// public string MaterialName { get; set; } + + /// + /// 物料类型:整包、尾料、溶剂 + /// public string MaterialType { get; set; } + + /// + /// 重量 + /// public string SetWeight { get; set; } + + /// + /// 误差值 + /// public string SetError { get; set; } + + /// + /// 工装区分,相同值代表在一个料桶中 + /// public string Difference { get; set; } + + /// + /// 是否有固含 1为有,0没有 + /// public string Fixed { get; set; } + + /// + /// 固含率 + /// public string FixedRatio { get; set; } + + /// + /// 泵条码 + /// public string PumpCode { get; set; } + + /// + /// 地磅 + /// public string Weighbridge { get; set; } + + /// + /// 配方号 + /// public string Recipe { get; set; } + + /// + /// 备注 + /// public string Remark { get; set; } + /// + /// 皮重 + /// public string Tare { get; set; } + /// + /// 反应釜编号 + /// public string MainId { get; set; } diff --git a/Admin.Core.Service/Service_New/BinFeedingReportServices.cs b/Admin.Core.Service/Service_New/BinFeedingReportServices.cs index 573e804..8628887 100644 --- a/Admin.Core.Service/Service_New/BinFeedingReportServices.cs +++ b/Admin.Core.Service/Service_New/BinFeedingReportServices.cs @@ -2,6 +2,11 @@ using Admin.Core.Service; using Admin.Core.IService; using Admin.Core.Model; +using System.Linq; +using System.Collections.Generic; +using System; +using log4net.Repository.Hierarchy; +using Serilog; namespace Admin.Core.Service { @@ -13,5 +18,25 @@ namespace Admin.Core.Service this._dal = dal; base.BaseDal = dal; } + + /// + /// 获取批次号 + /// + /// + /// + /// + public string GetBatchNumberByMaterialAndBinID(string materialID, int binID) + { + try + { + BinFeedingReport record = _dal.Query(x => x.MaterialID == materialID && x.BinID == binID).OrderBy(x => x.CreateTime).LastOrDefault(); + return record != null ? record.Material_BatchNumber : string.Empty; + } + catch(Exception ex) + { + Log.Error($"获取批次号发生错误:{ex.Message}"); + return string.Empty; + } + } } } \ No newline at end of file diff --git a/Admin.Core.Service/Service_New/Hw_BarrelServices.cs b/Admin.Core.Service/Service_New/Hw_BarrelServices.cs index c1644d7..af83390 100644 --- a/Admin.Core.Service/Service_New/Hw_BarrelServices.cs +++ b/Admin.Core.Service/Service_New/Hw_BarrelServices.cs @@ -2,6 +2,7 @@ using Admin.Core.IService; using Admin.Core.IService.IService_New; using Admin.Core.Model; +using Serilog; using System; using System.Collections.Generic; using System.Linq; @@ -24,12 +25,13 @@ namespace Admin.Core.Service.Service_New { try { - string planId = _dal.Query(x => x.BarCode == barrelBarcode).FirstOrDefault().PlanId.ToString(); + string planId = _dal.Query(x => x.BarCode == barrelBarcode).FirstOrDefault().PlanId; return planId; } - catch + catch(Exception ex) { - throw; + Log.Error($"获取计划ID错误:{ex}"); + return "-1"; } } } diff --git a/Admin.Core.Service/Service_New/Hw_WarehouseServices.cs b/Admin.Core.Service/Service_New/Hw_WarehouseServices.cs index 9da9f55..5017230 100644 --- a/Admin.Core.Service/Service_New/Hw_WarehouseServices.cs +++ b/Admin.Core.Service/Service_New/Hw_WarehouseServices.cs @@ -284,7 +284,7 @@ namespace Admin.Core.Service list.ForEach((a) => { Hw_WareHouse_Sub sb = new Hw_WareHouse_Sub(); - sb.MainId = int.Parse(a.MainId); + sb.MainId = int.TryParse(a.MainId, out int value) ? value : throw new Exception("MainID格式错误!请传入int类型的反应釜编号"); sb.PId = a.PId; sb.ProductName = a.ProductName; sb.MaterialID = a.Material_Code; @@ -492,7 +492,7 @@ namespace Admin.Core.Service list.ForEach((a) => { Hw_WareHouse_Sub sb = new Hw_WareHouse_Sub(); - sb.MainId = int.Parse(a.MainId); + sb.MainId = int.TryParse(a.MainId, out int value) ? value : throw new Exception("MainID格式错误!请传入int类型的反应釜编号"); sb.PId = a.PId; sb.ProductName = a.ProductName; sb.MaterialID = a.Material_Code; @@ -685,7 +685,7 @@ namespace Admin.Core.Service list.ForEach((a) => { Hw_WareHouse_Sub sb = new Hw_WareHouse_Sub(); - sb.MainId = int.Parse(a.MainId); + sb.MainId = int.TryParse(a.MainId, out int value) ? value : throw new Exception("MainID格式错误!请传入int类型的反应釜编号"); sb.PId = a.PId; sb.ProductName = a.ProductName; sb.BinId = a.BinId == "" || a.BinId == null ? 0 : int.Parse(a.BinId); @@ -763,7 +763,7 @@ namespace Admin.Core.Service throw new Exception("未查询到对应料仓!"); } - var binInfo = await _binRepository.FirstAsync(d => d.Bin_Serial == sub.BinId && d.Material_ID == obj.ID); + Pmt_Bin binInfo = await _binRepository.FirstAsync(d => d.Bin_Serial == sub.BinId && d.Material_ID == obj.ID); if (binInfo == null) { throw new Exception("未查询到对应料仓!"); @@ -1175,7 +1175,7 @@ namespace Admin.Core.Service } var s7 = PlcConnect.Instance; var result = s7.Write(name, short.Parse(state.ToString()));//反应釜点位 - log.Error($"反应釜开启点位状态:{result.IsSuccess},返回信息:{result.Message}"); + log.Info($"反应釜开启点位状态:{result.IsSuccess},返回信息:{result.Message}"); if (result.IsSuccess) { return result.IsSuccess;