using Admin.Core.IService; using Admin.Core.Service; using Admin.Core.IService.ISys; using Admin.Core.Model; using Admin.Core.Common.Resource; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System; using System.Collections.Generic; using System.Linq.Expressions; using System.Threading.Tasks; using Admin.Core.Common; using System.Linq; using Admin.Core.Model.ViewModels; using Microsoft.AspNetCore.Mvc.ViewEngines; using System.Collections; using NPOI.SS.Formula.Functions; namespace Admin.Core.Api.Controllers.Business { /// /// 反应釜防错验证 /// [Route("api/[controller]/[action]")] [ApiController] [AllowAnonymous] public class WarehouseController : BaseApiUserController { #region 整包信息 //000524-20230805-0001-CF-130|25kg //000524:为物料编码 //CF-130:物料名称 //25kg物料重量 #endregion /// /// 投料仓服务 /// private readonly IHw_WarehouseServices _hw_WarehouseService; #region 构造方法 /// /// 构造方法 /// /// /// public WarehouseController(IHw_WarehouseServices hw_WarehouseServices, ISysUserService sysUserService) : base(sysUserService) { _sysUserService = sysUserService; _hw_WarehouseService = hw_WarehouseServices; } #endregion #region 扫描料桶条码 获取桶绑定物料信息 /// /// 扫描料桶条码 获取桶绑定物料信息 /// /// 反应釜 /// 计划Id /// 料桶Id /// [HttpGet] public async Task> GetByBarrelInfo(string kettleBarCode, string planId,string code) { if (!code.IsNotEmptyOrNull()) { return Failed("传入参数为空!"); } var query = await _hw_WarehouseService.GetXlInfo(kettleBarCode.Trim(),planId.Trim(),code.Trim()); if (query == null) { return Failed("查询失败!"); } return Success(query); } #endregion #region 根据条码查询投料釜设置的物料 /// /// 根据条码查询投料釜设置的物料 /// /// 投料釜条码 /// 计划Id /// [HttpGet] public async Task> GetByCode(string code,string planId) { if (!code.IsNotEmptyOrNull()) { return Failed("传入物料编码参数为空!"); } if (!planId.IsNotEmptyOrNull()) { return Failed("传入计划ID参数为空!"); } var query = await _hw_WarehouseService.QueryByCode(code.Trim(), planId); if (query==null) { return Failed("查询失败!"); } return Success(query); } #endregion #region PLC更新状态——反应釜 /// /// PLC更新状态——反应釜 /// /// json 对象 /// [HttpPost] public async Task> ExecPlcState([FromBody] KettleView view) { if (!view.IsNotEmptyOrNull()) { return Failed("传入参数为空!"); } var result = await _hw_WarehouseService.UpdatePlcState(view); if (result) { return Success(result); } return Failed("执行失败!"); } [HttpPost] public async Task> DownLoadplanInfo([FromBody] List MesDownLoadPlanList) { try { int iFlag = 0; if (MesDownLoadPlanList == null || MesDownLoadPlanList.Count == 0) { return Failed("传入参数为空!"); } foreach (var item in MesDownLoadPlanList) { if (item.RecipeID == "") { return Failed("传入参数为空!"); } var result = await _hw_WarehouseService.InsertXLPlanInfo(DateTime.Now, item.RecipeID, item.Batch, item.ProductName); if (result) { iFlag = iFlag + 1; } } if (iFlag == MesDownLoadPlanList.Count) { return Success(true); } ////配方名或配方编号 //string ss1 = "a82d016e813c4ac3bca0244c519da591"; ////批次号 //string ss2 = "2408090522"; ////产品名称 //var ss3 = "D1-813"; } catch (Exception ex) { } return Failed("执行失败!"); } /// /// 投料口开/投料口关 /// /// /// /// [HttpGet] public async Task> ExecPlcState(string code,int state) { if (!code.IsNotEmptyOrNull() || !state.IsNotEmptyOrNull()) { return Failed("传入参数为空!"); } var result = await _hw_WarehouseService.UpdatePlcState(code,state); if (result) { return Success(result); } return Failed("执行失败!"); } /// /// 查询称量重量 /// /// /// [HttpGet] public async Task>> GetWeight() { //if (!WeightNo.IsNotEmptyOrNull()) //{ // return Failed("传入参数为空!"); //} //var result = await _hw_WarehouseService.RealWeightInfo(WeightNo); var result = await _hw_WarehouseService.GetPlanWeightInfo(); if (result != null) { return Success(result,"成功"); } return Failed>("执行失败!"); } #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 } }