using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Ys.Core.Common;
using djy.Paas.IService;
using djy.Paas.Model;
using Microsoft.AspNetCore.Authorization;
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using Hangfire;
using System.IO;
using Microsoft.AspNetCore.Hosting;
using NPOI.SS.Util;
namespace djyweb_djyPaasApi.Controllers
{
///
///外部结合跳转控制
///
public class BaoguanController : ApiBase
{
IBaoguanService _server = IOC.AddServer();
//货主端
IBaoguanOrderClientService _cservice = IOC.AddServer();
private string _moduleKey = "baoguanorder";
#region 货主
///
/// 货主报关单查询
///
///
///
///
[HttpGet("client")]
public object ClientList([FromQuery] BaoguanOrderClientDto Dto, [FromQuery] ApiFromDto apiFrom)
{
var aut = GetUserAuthorityToFormDto(_moduleKey);
if (!aut.IsPower)
{
return new ReturnResult() { Message = "没有权限" };
}
Dto.CompGId = aut.CompayId;
Dto.UserGid = aut.UserId;
return _cservice.GetList(Dto, apiFrom);
}
///
/// 货主端创建
///
///
///
[HttpPost("client")]
public object Clientorderadd([FromBody] tb_BaoguanOrderClient Dto)
{
var rs = new ReturnResult();
Dto.UserGid = GetLoginId;
Dto.CompGId = Guid.Parse(GetUserInfo().CompId);
if (Dto.ShipOrderNo.IsNull() || Dto.IEFlag.IsNull() || Dto.BaoguanAgent.IsNull())
{
rs.Not("进出口类型 提单号 报关行不允许为空!");
return rs;
}
if (Dto.FileUrl.IsNull())
{
rs.Not("请上传资料文件");
return rs;
}
var list = _cservice.GetList(new BaoguanOrderClientDto { ShipOrderNo = Dto.ShipOrderNo, CompGId = Dto.CompGId }, new ApiFromDto());
if (list.Count > 0)
{
rs.Not("此提单号已经提交过了");
return rs;
}
return _cservice.Add(Dto);
}
///
/// 更新 货主端海关单
///
///
///
[HttpPost("client/up")]
public object ClientOrderUp([FromBody] tb_BaoguanOrderClient Dto)
{
if (Dto == null)
{
return new ReturnResult