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