|
|
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;
|
|
|
<<<<<<< HEAD
|
|
|
using TouchSocket.Core;
|
|
|
=======
|
|
|
using System.Numerics;
|
|
|
using Admin.Core.IService.IService_New;
|
|
|
>>>>>>> dep_wangsr
|
|
|
|
|
|
namespace Admin.Core.Api.Controllers.Business
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 反应釜防错验证
|
|
|
/// </summary>
|
|
|
[Route("api/[controller]/[action]")]
|
|
|
[ApiController]
|
|
|
[AllowAnonymous]
|
|
|
public class WarehouseController : BaseApiUserController
|
|
|
{
|
|
|
#region 整包信息
|
|
|
//000524-20230805-0001-CF-130|25kg
|
|
|
//000524:为物料编码
|
|
|
//CF-130:物料名称
|
|
|
//25kg物料重量
|
|
|
#endregion
|
|
|
|
|
|
/// <summary>
|
|
|
/// 投料仓服务
|
|
|
/// </summary>
|
|
|
private readonly IHw_WarehouseServices _hw_WarehouseService;
|
|
|
|
|
|
/// <summary>
|
|
|
/// 料筒服务类
|
|
|
/// </summary>
|
|
|
private readonly IHw_BarrelServices _hw_BarrelService;
|
|
|
|
|
|
/// <summary>
|
|
|
/// 称重服务类
|
|
|
/// </summary>
|
|
|
private readonly ILR_weighServices _lr_weighService;
|
|
|
|
|
|
#region 构造方法
|
|
|
/// <summary>
|
|
|
/// 构造方法
|
|
|
/// </summary>
|
|
|
/// <param name="hw_WarehouseServices"></param>
|
|
|
/// <param name="sysUserService"></param>
|
|
|
/// <param name="hwBarrelService"></param>
|
|
|
/// <param name="lrweighService"></param>
|
|
|
public WarehouseController(IHw_WarehouseServices hw_WarehouseServices, ISysUserService sysUserService, IHw_BarrelServices hwBarrelService, ILR_weighServices lrweighService) : base(sysUserService)
|
|
|
{
|
|
|
_sysUserService = sysUserService;
|
|
|
_hw_WarehouseService = hw_WarehouseServices;
|
|
|
_hw_BarrelService = hwBarrelService;
|
|
|
_lr_weighService = lrweighService;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 扫描料桶条码 获取桶绑定物料信息
|
|
|
/// <summary>
|
|
|
/// 扫描料桶条码 获取桶绑定物料信息
|
|
|
/// </summary>
|
|
|
/// <param name="kettleBarCode">反应釜</param>
|
|
|
/// <param name="planId">计划Id</param>
|
|
|
/// <param name="code">料桶Id</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpGet]
|
|
|
public async Task<MessageModel<BarrelView>> GetByBarrelInfo(string kettleBarCode, string planId, string code)
|
|
|
{
|
|
|
if (!code.IsNotEmptyOrNull())
|
|
|
{
|
|
|
return Failed<BarrelView>("传入参数为空!");
|
|
|
}
|
|
|
var query = await _hw_WarehouseService.GetXlInfo(kettleBarCode.Trim(), planId.Trim(), code.Trim());
|
|
|
if (query == null)
|
|
|
{
|
|
|
return Failed<BarrelView>("查询失败!");
|
|
|
}
|
|
|
return Success(query);
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 根据条码查询投料釜设置的物料
|
|
|
/// <summary>
|
|
|
/// 根据条码查询投料釜设置的物料
|
|
|
/// </summary>
|
|
|
/// <param name="code">投料釜条码</param>
|
|
|
/// <param name="planId">计划Id</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpGet]
|
|
|
public async Task<MessageModel<WarehouseView>> GetByCode(string code, string planId)
|
|
|
{
|
|
|
|
|
|
if (!code.IsNotEmptyOrNull())
|
|
|
{
|
|
|
return Failed<WarehouseView>("传入物料编码参数为空!");
|
|
|
}
|
|
|
if (!planId.IsNotEmptyOrNull())
|
|
|
{
|
|
|
return Failed<WarehouseView>("传入计划ID参数为空!");
|
|
|
}
|
|
|
var query = await _hw_WarehouseService.QueryByCode(code.Trim(), planId);
|
|
|
|
|
|
if (query == null)
|
|
|
{
|
|
|
return Failed<WarehouseView>("查询失败!");
|
|
|
}
|
|
|
return Success(query);
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region PLC更新状态——反应釜
|
|
|
/// <summary>
|
|
|
/// PLC更新状态——反应釜
|
|
|
/// </summary>
|
|
|
/// <param name="view">json 对象</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost]
|
|
|
public async Task<MessageModel<bool>> ExecPlcState([FromBody] KettleView view)
|
|
|
{
|
|
|
if (!view.IsNotEmptyOrNull())
|
|
|
{
|
|
|
return Failed<bool>("传入参数为空!");
|
|
|
}
|
|
|
var result = await _hw_WarehouseService.UpdatePlcState(view);
|
|
|
if (result)
|
|
|
{
|
|
|
return Success(result);
|
|
|
}
|
|
|
return Failed<bool>("执行失败!");
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// MES计划下发
|
|
|
/// </summary>
|
|
|
/// <param name="MesDownLoadPlanList"></param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost]
|
|
|
public async Task<MessageModel<bool>> DownLoadplanInfo([FromBody] List<MesDownLoadPlanList> MesDownLoadPlanList)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
if (MesDownLoadPlanList == null || MesDownLoadPlanList.Count == 0)
|
|
|
{
|
|
|
return Failed<bool>("传入参数为空!");
|
|
|
}
|
|
|
string result1 = await _hw_WarehouseService.DownRJPlanAsync(MesDownLoadPlanList);
|
|
|
string result2 = await _hw_WarehouseService.DownZBPlanAsync(MesDownLoadPlanList);
|
|
|
string result3 = await _hw_WarehouseService.DownXLPlanAsync(MesDownLoadPlanList);
|
|
|
|
|
|
|
|
|
if (result1.Contains("成功"))
|
|
|
{
|
|
|
if (result2.Contains("成功"))
|
|
|
{
|
|
|
if (result3.Contains("成功"))
|
|
|
{
|
|
|
return Success(true);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return Failed<bool>(result3 + "执行失败!");
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return Failed<bool>(result2 + "执行失败!");
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return Failed<bool>(result1 + "执行失败!");
|
|
|
}
|
|
|
|
|
|
|
|
|
////配方名或配方编号
|
|
|
//string ss1 = "a82d016e813c4ac3bca0244c519da591";
|
|
|
////批次号
|
|
|
//string ss2 = "2408090522";
|
|
|
////产品名称
|
|
|
//var ss3 = "D1-813";
|
|
|
|
|
|
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
return Failed<bool>(ex.Message + "执行失败!");
|
|
|
}
|
|
|
return Failed<bool>("执行失败!");
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 投料口开/投料口关
|
|
|
/// </summary>
|
|
|
/// <param name="code"></param>
|
|
|
/// <param name="state"></param>
|
|
|
/// <returns></returns>
|
|
|
[HttpGet]
|
|
|
public async Task<MessageModel<bool>> ExecPlcState(string code, int state)
|
|
|
{
|
|
|
if (!code.IsNotEmptyOrNull() || !state.IsNotEmptyOrNull())
|
|
|
{
|
|
|
return Failed<bool>("传入参数为空!");
|
|
|
}
|
|
|
var result = await _hw_WarehouseService.UpdatePlcState(code, state);
|
|
|
if (result)
|
|
|
{
|
|
|
return Success(result);
|
|
|
}
|
|
|
return Failed<bool>("执行失败!");
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 查询称量信息
|
|
|
/// </summary>
|
|
|
/// <param name="WeightNo"></param>
|
|
|
/// <returns></returns>
|
|
|
[HttpGet]
|
|
|
public async Task<MessageModel<List<XLPlanWeightView>>> GetWeight()
|
|
|
{
|
|
|
//if (!WeightNo.IsNotEmptyOrNull())
|
|
|
//{
|
|
|
// return Failed<string>("传入参数为空!");
|
|
|
//}
|
|
|
//var result = await _hw_WarehouseService.RealWeightInfo(WeightNo);
|
|
|
var result = await _hw_WarehouseService.GetPlanWeightInfo();
|
|
|
if (result != null)
|
|
|
{
|
|
|
return Success(result, "成功");
|
|
|
}
|
|
|
return Failed<List<XLPlanWeightView>>("执行失败!");
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 查询反应釜计划
|
|
|
/// <summary>
|
|
|
/// 查询反应釜计划
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
[HttpGet]
|
|
|
public async Task<MessageModel<List<string>>> GetWarehousePlan(string code)
|
|
|
{
|
|
|
MessageModel<List<string>> messageModel = new MessageModel<List<string>>();
|
|
|
List<string> 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
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据罐号查询称量列表
|
|
|
/// </summary>
|
|
|
/// <param name="barrelID"></param>
|
|
|
/// <returns></returns>
|
|
|
[HttpGet]
|
|
|
public async Task<MessageModel<List<LR_weigh>>> GetWeightInfoByBarrelID(string barrelBarcode)
|
|
|
{
|
|
|
if (!barrelBarcode.IsNotEmptyOrNull())
|
|
|
{
|
|
|
return Failed<List<LR_weigh>>("传入参数为空!");
|
|
|
}
|
|
|
MessageModel<List<LR_weigh>> messageModel = new MessageModel<List<LR_weigh>>();
|
|
|
string planID = _hw_BarrelService.GetPlanIdByBarrelID(barrelBarcode.Trim());
|
|
|
if (string.IsNullOrEmpty(planID))
|
|
|
{
|
|
|
return Failed<List<LR_weigh>>("查询不到罐号对应的计划ID!");
|
|
|
}
|
|
|
List<LR_weigh> list = _lr_weighService.GetRecentWeightList(planID);
|
|
|
if (list != null)
|
|
|
{
|
|
|
return Success(list);
|
|
|
}
|
|
|
return Failed<List<LR_weigh>>("执行失败!");
|
|
|
|
|
|
}
|
|
|
}
|
|
|
} |