diff --git a/Admin.Core.Api/Admin.Core.Api.xml b/Admin.Core.Api/Admin.Core.Api.xml index d81b0c9..5521fdc 100644 --- a/Admin.Core.Api/Admin.Core.Api.xml +++ b/Admin.Core.Api/Admin.Core.Api.xml @@ -271,7 +271,7 @@ - 小料料仓类型放差错 + 小料料仓类型防差错 @@ -389,11 +389,12 @@ 桶条码 - + 根据条码查询投料釜设置的物料 投料釜条码 + 计划Id @@ -403,6 +404,12 @@ json 对象 + + + 查询反应釜计划 + + + Controller代码生成 diff --git a/Admin.Core.Api/Admin.Core.Model.xml b/Admin.Core.Api/Admin.Core.Model.xml index e08be31..83aca08 100644 --- a/Admin.Core.Api/Admin.Core.Model.xml +++ b/Admin.Core.Api/Admin.Core.Model.xml @@ -362,6 +362,11 @@ Nullable:True + + + 类型 + + diff --git a/Admin.Core.Api/Controllers/Business/MaterialController.cs b/Admin.Core.Api/Controllers/Business/MaterialController.cs index 2dc92b6..8e9bf8f 100644 --- a/Admin.Core.Api/Controllers/Business/MaterialController.cs +++ b/Admin.Core.Api/Controllers/Business/MaterialController.cs @@ -15,7 +15,7 @@ using log4net; namespace Admin.Core.Api { /// - /// 小料料仓类型放差错 + /// 小料料仓类型防差错 /// [Route("api/[controller]/[action]")] [ApiController] @@ -206,6 +206,7 @@ namespace Admin.Core.Api /// /// [HttpGet] + [Obsolete("废弃")] public async Task>> GetXlPlanInfo() { MessageModel> message=new MessageModel>(); diff --git a/Admin.Core.Api/Controllers/Business/SolventController.cs b/Admin.Core.Api/Controllers/Business/SolventController.cs index 36ac05f..cdc1dc1 100644 --- a/Admin.Core.Api/Controllers/Business/SolventController.cs +++ b/Admin.Core.Api/Controllers/Business/SolventController.cs @@ -36,7 +36,7 @@ namespace Admin.Core.Api { _sysUserService = sysUserService; this._solventServices = solventServices; - } + } #endregion #region 拉缸验证物料 @@ -44,16 +44,16 @@ namespace Admin.Core.Api /// 根据拉缸条码查询物料 /// /// 缸条码 + /// 地磅名称:1号地磅|2号地磅 /// [HttpGet] - public async Task> GetByCylinderInfo(string code) + public async Task> GetByCylinderInfo(string code,string weighbridge) { - string weighbridge = "1号地磅"; if (!code.IsNotEmptyOrNull()) { return Failed("传入参数为空!"); } - var query = await _solventServices.GetByCylinderCode(code.Trim(),weighbridge); + var query = await _solventServices.GetByCylinderCode(code.Trim(),weighbridge.Trim()); if (query == null) { return Failed("查询失败!"); @@ -142,6 +142,7 @@ namespace Admin.Core.Api /// /// [HttpGet] + [Obsolete("废弃")] public async Task>> GetSolventPlanInfo() { MessageModel> message = new MessageModel>(); diff --git a/Admin.Core.Api/Controllers/Business/WarehouseController.cs b/Admin.Core.Api/Controllers/Business/WarehouseController.cs index c37494d..a5a6da5 100644 --- a/Admin.Core.Api/Controllers/Business/WarehouseController.cs +++ b/Admin.Core.Api/Controllers/Business/WarehouseController.cs @@ -32,7 +32,6 @@ namespace Admin.Core.Api.Controllers.Business //25kg物料重量 #endregion - /// /// 投料仓服务 /// @@ -49,23 +48,6 @@ namespace Admin.Core.Api.Controllers.Business _hw_WarehouseService = hw_WarehouseServices; } - #region 获取反应釜所有计划号 - ///// - ///// 获取反应釜所有计划号 - ///// - ///// - //[HttpGet] - //public async Task>> GetAllPlan() - //{ - // var query = await _hw_WarehouseService.GetPlan(); - // if (query == null) - // { - // return Failed>("未查询到计划号!"); - // } - // return Success(query); - //} - #endregion - #region 扫描料桶条码 获取桶绑定物料信息 /// /// 扫描料桶条码 获取桶绑定物料信息 @@ -93,16 +75,21 @@ namespace Admin.Core.Api.Controllers.Business /// 根据条码查询投料釜设置的物料 /// /// 投料釜条码 + /// 计划Id /// [HttpGet] - public async Task> GetByCode(string code) + public async Task> GetByCode(string code,string planId) { if (!code.IsNotEmptyOrNull()) { - return Failed("传入参数为空!"); + return Failed("传入物料编码参数为空!"); + } + if (!planId.IsNotEmptyOrNull()) + { + return Failed("传入计划ID参数为空!"); } - var query = await _hw_WarehouseService.QueryByCode(code.Trim()); + var query = await _hw_WarehouseService.QueryByCode(code.Trim(), planId); if (query==null) { @@ -134,5 +121,29 @@ namespace Admin.Core.Api.Controllers.Business } #endregion + + #region 查询反应釜计划 + /// + /// 查询反应釜计划 + /// + /// + [HttpGet] + public async Task>> GetWarehousePlan(string code) + { + MessageModel> messageModel = new MessageModel>(); + List list = await _hw_WarehouseService.GetWarehousePlan(code); + if (list == null) + { + messageModel.success = false; + messageModel.msg = "未查询到数据"; + return messageModel; + } + messageModel.success = true; + messageModel.data = list; + return Success(list); + } + #endregion + + } } \ No newline at end of file diff --git a/Admin.Core.Api/appsettings.Development.json b/Admin.Core.Api/appsettings.Development.json index f76603e..b196aa1 100644 --- a/Admin.Core.Api/appsettings.Development.json +++ b/Admin.Core.Api/appsettings.Development.json @@ -82,7 +82,7 @@ "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=haiwei@123;Integrated Security=false;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", + "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", diff --git a/Admin.Core.Extensions/Middlewares/QuartzJobMildd.cs b/Admin.Core.Extensions/Middlewares/QuartzJobMildd.cs index c29371a..da51152 100644 --- a/Admin.Core.Extensions/Middlewares/QuartzJobMildd.cs +++ b/Admin.Core.Extensions/Middlewares/QuartzJobMildd.cs @@ -15,7 +15,7 @@ namespace Admin.Core.Extensions public static class QuartzJobMildd { private static readonly ILog log = LogManager.GetLogger(typeof(QuartzJobMildd)); - public static void UseQuartzJobMildd(this IApplicationBuilder app, ISysTasksQzService tasksQzService, ISchedulerCenter schedulerCenter) + public static async Task UseQuartzJobMildd(this IApplicationBuilder app, ISysTasksQzService tasksQzService, ISchedulerCenter schedulerCenter) { if (app == null) throw new ArgumentNullException(nameof(app)); @@ -24,7 +24,7 @@ namespace Admin.Core.Extensions if (Appsettings.app("Middleware", "QuartzNetJob", "Enabled").ObjToBool()) { //**注意在此处查询《wpf异步查询不到改为同步》** - var allQzServices = tasksQzService.Query(x => x.DelFlag == false); + var allQzServices =await tasksQzService.QueryAsync(x => x.DelFlag == false); foreach (var item in allQzServices) { if ((bool)item.IsStart) diff --git a/Admin.Core.IService/IService_New/IHw_WarehouseServices.cs b/Admin.Core.IService/IService_New/IHw_WarehouseServices.cs index d6985a3..2ae646b 100644 --- a/Admin.Core.IService/IService_New/IHw_WarehouseServices.cs +++ b/Admin.Core.IService/IService_New/IHw_WarehouseServices.cs @@ -12,10 +12,9 @@ namespace Admin.Core.IService /// public interface IHw_WarehouseServices : IBaseServices { - - Task QueryByCode(string code); + Task QueryByCode(string code,string planId); Task UpdatePlcState(KettleView view); Task GetXlInfo(string code); - Task> GetPlan(); + Task> GetWarehousePlan(string code); } } \ No newline at end of file diff --git a/Admin.Core.Model/ViewModels/VerifyView.cs b/Admin.Core.Model/ViewModels/VerifyView.cs index bc785f3..e3da5c9 100644 --- a/Admin.Core.Model/ViewModels/VerifyView.cs +++ b/Admin.Core.Model/ViewModels/VerifyView.cs @@ -126,6 +126,14 @@ namespace Admin.Core.Model.ViewModels /// /// 地磅名称 /// - public string Weighbridge { get; set; } + public string Weighbridge { get; set; } + /// + /// 是否有固含 + /// + public bool IsRate { get; set; } + /// + /// 固含率 + /// + public double Rate { get; set; } } } \ No newline at end of file diff --git a/Admin.Core.Model/ViewModels/WaitePlanView.cs b/Admin.Core.Model/ViewModels/WaitePlanView.cs index 69ef99c..787a203 100644 --- a/Admin.Core.Model/ViewModels/WaitePlanView.cs +++ b/Admin.Core.Model/ViewModels/WaitePlanView.cs @@ -103,5 +103,9 @@ namespace Admin.Core.Model.ViewModels /// 待执行物料是否执行过 /// public string MaterialPlan { get; set; } + /// + /// 是否有固含 1:有;0:无 + /// + public int IsRate { get; set; } } } diff --git a/Admin.Core.PlcServer/IPlc.cs b/Admin.Core.PlcServer/IPlc.cs index ca20ddf..791c217 100644 --- a/Admin.Core.PlcServer/IPlc.cs +++ b/Admin.Core.PlcServer/IPlc.cs @@ -98,6 +98,13 @@ namespace Admin.Core.PlcServer /// bool WriteFloat(string address, float value); /// + /// 写入double + /// + /// + /// + /// + bool Writedouble(string address, double value); + /// /// 心跳使用——喂狗 /// /// diff --git a/Admin.Core.PlcServer/Impl/SiemensPlc.cs b/Admin.Core.PlcServer/Impl/SiemensPlc.cs index 3069b31..f7bb3d3 100644 --- a/Admin.Core.PlcServer/Impl/SiemensPlc.cs +++ b/Admin.Core.PlcServer/Impl/SiemensPlc.cs @@ -429,6 +429,39 @@ namespace Admin.Core.PlcServer } + #endregion + + #region 写入double + /// + /// 写入byte + /// + /// + /// + /// + public bool Writedouble(string address, double value) + { + bool iflag = false; + try + { + OperateResult write = siemensS7Net.Write(address, value); + if (write.IsSuccess) + { + iflag = true; + } + else + { + iflag = false; + } + } + catch (Exception ex) + { + log.Error("WriteByte方法异常" + ex.ToString()); + iflag = false; + } + return iflag; + } + + #endregion #region 心跳使用——喂狗 @@ -437,7 +470,7 @@ namespace Admin.Core.PlcServer /// /// /// - public async Task Read(string address) + public async Task Read(string address) { try { diff --git a/Admin.Core.Repository/Repository_New/Hw_weighRepository.cs b/Admin.Core.Repository/Repository_New/Hw_weighRepository.cs index 5a2a710..e7722c7 100644 --- a/Admin.Core.Repository/Repository_New/Hw_weighRepository.cs +++ b/Admin.Core.Repository/Repository_New/Hw_weighRepository.cs @@ -18,9 +18,9 @@ namespace Admin.Core.Repository public async Task> GetWaiteMaterial(string planId) { 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 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 + hw.Plan_ID MaterialPlan,ISNULL(r.IsRate,0) as IsRate 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.Material_ID=m.ID and p.Real_Num=hw.Dosing_ID where p.Plan_State=3 ORDER BY w.Weight_Id"; SugarParameter[] parameters = new SugarParameter[] { diff --git a/Admin.Core.Service/Service_New/Hw_WarehouseServices.cs b/Admin.Core.Service/Service_New/Hw_WarehouseServices.cs index e5a85f2..48373d3 100644 --- a/Admin.Core.Service/Service_New/Hw_WarehouseServices.cs +++ b/Admin.Core.Service/Service_New/Hw_WarehouseServices.cs @@ -21,6 +21,7 @@ namespace Admin.Core.Service private readonly IHw_BarrelRepository _barrel; private readonly Ixl_materialRepository _materialRepository; private readonly 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) { this._dal = dal; @@ -73,15 +74,14 @@ namespace Admin.Core.Service /// /// /// - public async Task QueryByCode(string code) + public async Task QueryByCode(string code, string planId) { try { - var list = await _wareHouse.QueryAsync(); - if (list == null) return null; - Hw_Warehouse wh = list.FirstOrDefault(d => d.BarCode == code); + 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); + var sub = await _wareHouse_Sub.QueryAsync(d => d.MainId == wh.ID&& d.PId== planId); + if (sub == null) return null; WarehouseView warehouseView = new WarehouseView() { @@ -101,8 +101,6 @@ namespace Admin.Core.Service return null; } } - - #endregion #region 更新PLC状态 @@ -271,22 +269,15 @@ namespace Admin.Core.Service /// 获取所有计划号 /// /// - public async Task> GetPlan() + public async Task> GetWarehousePlan(string code) { - List strList = new List(); - List list = await _wareHouse.QueryAsync(); - if (list.Count == 0) return null; - list.ForEach(d => { - if (!string.IsNullOrEmpty(d.PlanId)) - { - strList.Add(d.PlanId); - } - }); - return strList; + Hw_Warehouse wh = await _wareHouse.FirstAsync(d=>d.BarCode== code); + if (wh==null) return null; + var list = await _wareHouse_Sub.QueryAsync(d=>d.MainId== wh.ID); + var planList = (from d in list + select d.PId).Distinct(); + return planList.ToList(); } - #endregion - - } } \ 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 70abdaf..58530f9 100644 --- a/Admin.Core.Service/Service_New/SolventServices.cs +++ b/Admin.Core.Service/Service_New/SolventServices.cs @@ -57,6 +57,7 @@ namespace Admin.Core.Service if (view.Weighbridge == "1号地磅") { bool matCode = plcList.plc.WriteInt16("DB110.DBW400.0", "1");//执行启动 + bool writeDouble = plcList.plc.Writedouble("DB110.DBW401.0", view.Rate);//传入固率 if (matCode) { Hw_SolventErrorPreventionReport report = new Hw_SolventErrorPreventionReport() @@ -327,39 +328,26 @@ namespace Admin.Core.Service /// 拉缸查询 /// /// + /// /// public async Task GetByCylinderCode(string code, string weighbridge) { try { + var list = await _planRepository.GetDownLoadPlan(code, weighbridge); + if (list.Count == 0) return null; + var plan = list.FirstOrDefault(); + + var hwWeighList = await _hwWeighRepository.GetWaiteMaterial(plan.Plan_Id); + if (hwWeighList == null) return null; var plcList = PlcHelper.siemensList.SingleOrDefault(d => d.EquipName.Equals("溶剂PLC")); if (plcList.plc.IsConnected) { - var list = await _planRepository.GetDownLoadPlan(code, weighbridge); - if (list.Count == 0) return null; - var plan = list.FirstOrDefault(); - - var hwWeighList = await _hwWeighRepository.GetWaiteMaterial(plan.Plan_Id); - if (hwWeighList == null) return null; - if (plcList.plc.IsConnected) + int endStatus = plcList.plc.ReadInt16("DB110.DBW6.0");//完成信号 + if (endStatus == 1) { - int endStatus = plcList.plc.ReadInt16("DB110.DBW6.0");//完成信号 - if (endStatus == 1) - { - int planNum = plcList.plc.ReadInt16("DB110.DBW2.0");//执行批次 - if (plan.Plan_Num > plan.Real_Num) - { - 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; - - return hwWeigh; - } - } - else + int planNum = plcList.plc.ReadInt16("DB110.DBW2.0");//执行批次 + if (plan.Plan_Num > plan.Real_Num) { var rtPlanList = await _planRepository.QueryAsync(d => d.Plan_State == 3); var rtPlan = rtPlanList.FirstOrDefault(d => d.Plan_Id == plan.Plan_Id); @@ -371,8 +359,18 @@ namespace Admin.Core.Service 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; + var hwWeigh = hwWeighList.FirstOrDefault(d => d.MID == execNum); + if (hwWeigh == null) return null; + + return hwWeigh; + } + } return null; } catch (System.Exception ex)