|
|
|
|
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>("传入参数为空!");
|
|
|
|
|
}
|
|
|
|
|
view.Weighbridge = "1号地磅";
|
|
|
|
|
var result = await _solventServices.ExecPlcState(view);
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
return Success(result);
|
|
|
|
|
}
|
|
|
|
|
return Failed<bool>("执行失败!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#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>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[Obsolete("废弃")]
|
|
|
|
|
public async Task<MessageModel<List<SolventPlanView>>> GetSolventPlanInfo()
|
|
|
|
|
{
|
|
|
|
|
MessageModel<List<SolventPlanView>> message = new MessageModel<List<SolventPlanView>>();
|
|
|
|
|
var list = await _solventServices.GetSolventPlanInfo();
|
|
|
|
|
if (list.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
message.success = true;
|
|
|
|
|
message.data = list;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
message.success = false;
|
|
|
|
|
message.msg = "未查询到计划数据!";
|
|
|
|
|
}
|
|
|
|
|
return message;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|