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 Admin.Core.Service.Sys;
using Admin.Core.Model.ViewModels;
using System.Collections;
using NPOI.SS.Formula.Functions;
using System.Numerics;
namespace Admin.Core.Api
{
///
/// 溶剂称量 PDA接口
///
[Route("api/[controller]/[action]")]
[ApiController]
[AllowAnonymous]
public class SolventController : BaseApiUserController
{
private readonly ISolventServices _solventServices;
#region 构造函数
///
/// 构造函数
///
public SolventController(ISysUserService sysUserService, ISolventServices solventServices) : base(sysUserService)
{
_sysUserService = sysUserService;
this._solventServices = solventServices;
}
#endregion
#region 拉缸验证物料
///
/// 根据拉缸条码查询物料
///
/// 缸条码
/// 地磅名称:1号地磅|2号地磅
///
[HttpGet]
public async Task> GetByCylinderInfo(string code,string weighbridge)
{
if (!code.IsNotEmptyOrNull())
{
return Failed("传入参数为空!");
}
var query = await _solventServices.GetByCylinderCode(code.Trim(),weighbridge.Trim());
if (query == null)
{
return Failed("未查询到计划信息!");
}
return Success(query);
}
///
/// 拉缸执行PLC更改状态
///
///
///
[HttpPost]
public async Task> ExecPlcState([FromBody] VerifyView view)
{
if (!view.IsNotEmptyOrNull())
{
return Failed("传入参数为空!");
}
MessageModel result = await _solventServices.ExecPlcState(view);
if (result.success)
{
return result;
}
return result;
}
#endregion
#region 根据泵条码比对拉缸条码
///
/// 根据泵条码比对拉缸条码
///
/// 泵条码
///
[HttpGet]
public async Task> GetByPumpInfo(string code)
{
if (!code.IsNotEmptyOrNull())
{
return Failed("传入参数为空!");
}
var query = await _solventServices.GetByPumpCode(code.Trim());
if (query == null)
{
return Failed("查询失败!");
}
return Success(query);
}
///
/// 对比泵和拉缸条码匹配成功执行
///
/// 计划ID
/// 泵Code
/// 拉缸Code
///
[HttpGet]
public async Task> ExecState(string planId, string pumpCode, string cylinderCode)
{
if (!planId.IsNotEmptyOrNull())
{
return Failed("传入计划参数为空!");
}
if (!pumpCode.IsNotEmptyOrNull())
{
return Failed("传入泵参数为空!");
}
if (!cylinderCode.IsNotEmptyOrNull())
{
return Failed("传入拉缸参数为空!");
}
var query = await _solventServices.ExecState(planId, pumpCode.Trim(), cylinderCode.Trim());
if (query)
{
return Success(query);
}
return Failed("查询失败!");
}
#endregion
#region 查询整包称量物料
///
/// 整包物料查询
///
/// 整包物料编码
/// 地磅名称:1号地磅|2号地磅
///
[HttpGet]
public async Task> GetByZbCode(string code, string weighbridge)
{
if (!code.IsNotEmptyOrNull())
{
return Failed("传入物料条码参数为空!");
}
if (!weighbridge.IsNotEmptyOrNull())
{
return Failed("传入地磅参数为空!");
}
var query = await _solventServices.GetByZbCode(code.Trim(), weighbridge.Trim());
if (query == null)
{
return Failed("未查询到计划信息!");
}
return Success(query);
}
#endregion
}
}