using Amazon.Runtime.Internal.Util;
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.Module.Core.Helpers;
using DS.Module.DjyRulesEngine;
using DS.WMS.Core.Info.Dtos;
using DS.WMS.Core.Info.Interface;
using DS.WMS.Core.Op.Dtos;
using DS.WMS.Core.Op.EDI;
using DS.WMS.Core.Op.Interface;
using DS.WMS.Core.Sys.Dtos;
using DS.WMS.Core.Sys.Interface;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using NPOI.XWPF.UserModel;
using Org.BouncyCastle.Ocsp;
using System.Net;
namespace DS.WMS.OpApi.Controllers;
///
/// 海运出口信息-模块
///
public class SeaExportController : ApiController
{
private readonly ISeaExportService _invokeService;
private readonly ISeaExportCommonService _commonService;
///
/// 构造函数
///
///
public SeaExportController(ISeaExportService invokeService, ISeaExportCommonService commonService)
{
_invokeService = invokeService;
_commonService = commonService;
}
///
/// 列表
///
///
///
[HttpPost]
[Route("GetSeaExportList")]
public async Task> GetSeaExportList([FromBody] PageRequest request)
{
var res = await _invokeService.GetListByPage(request);
return res;
}
///
/// 海运出口分单列表
///
/// 传参ParentId等于主单id
///
[HttpPost]
[Route("GetSeaExportPartList")]
public async Task>> GetSeaExportPartList([FromBody] PageRequest request)
{
var res = await _invokeService.GetSeaExportPartList(request);
return res;
}
///
/// 编辑
///
///
///
[HttpPost]
[Route("EditSeaExport")]
public async Task EditSeaExport([FromBody] SeaExportReq req)
{
var res = await _invokeService.EditSeaExport(req);
return res;
}
///
/// 详情
///
///
///
[HttpGet]
[Route("GetSeaExportInfo")]
public DataResult GetSeaExportInfo([FromQuery] string id)
{
var res = _invokeService.GetSeaExportInfo(id);
return res;
}
///
/// 批量编辑
///
///
///
[HttpPost]
[Route("SeaExportBatchEdit")]
public DataResult SeaExportBatchEdit([FromBody] SeaExportBatchEditReq req)
{
var res = _invokeService.SeaExportBatchEdit(req);
return res;
}
///
/// 业务单据删除
///
///
///
[HttpGet]
[Route("SeaExportDel")]
public DataResult SeaExportDel([FromQuery] string id)
{
var res = _invokeService.SeaExportDel(id);
return res;
}
///
/// 业务单据批量删除
///
///
///
[HttpPost]
[Route("SeaExportBatchDel")]
public DataResult SeaExportBatchDel([FromBody] IdModel req)
{
var res = _invokeService.SeaExportBatchDel(req);
return res;
}
///
/// 业务单据复制-单票
///
///
///
[HttpGet]
[Route("SeaExportCopy")]
public DataResult SeaExportCopy([FromQuery] string id)
{
var res = _invokeService.SeaExportCopy(id);
return res;
}
///
/// 获取场站数据
///
/// 业务Id
/// 是否网站数据 默认false
///
[HttpGet]
[Route("GetYardData")]
public async Task> GetYardData([FromQuery] string id, bool isWeb = false)
{
return await _invokeService.GetYardData(id, isWeb);
}
///
/// 发起运踪订阅或者更新提单号
///
///
///
[HttpPost]
[Route("SendOrUpdateTrace")]
public async Task> SendOrUpdateTrace([FromBody]List req)
{
return await _invokeService.SendOrUpdateTrace(req);
}
///
/// 运踪退订
///
///
///
[HttpPost]
[Route("UnsubscribeBillTrace")]
public async Task> UnsubscribeBillTrace([FromBody]List req)
{
return await _invokeService.UnsubscribeBillTrace(req);
}
///
/// 获取VGM、VGM SI链接
///
/// 业务Id
///
[HttpGet]
[Route("VgmLink")]
public async Task> VgmLink([FromQuery] string id)
{
return await _invokeService.VgmLink(id);
}
///
/// 发送VGM
///
/// 业务Id
///
[HttpGet]
[Route("VgmSend")]
public async Task> VgmSend([FromQuery] string id)
{
return await _invokeService.VgmSend(id);
}
///
/// 批量获取vgm
///
/// 业务id 逗号拼接
///
[HttpGet]
[Route("GetVmgDataList")]
public async Task>> GetVmgDataList([FromQuery] string ids)
{
return await _invokeService.GetVmgDataList(ids);
}
///
/// 批量保存vgm
///
///
///
[HttpPost]
[Route("SaveBatchVgm")]
public async Task> SaveBatchVgm([FromBody] List req)
{
return await _invokeService.SaveBatchVgm(req);
}
///
/// 获取提箱小票链接
///
/// 业务Id
///
[HttpGet]
[Route("TxxpLink")]
public async Task> TxxpLink([FromQuery] string id)
{
return await _invokeService.TxxpLink(id);
}
///
/// 检查是否VOLTA并返回初始数据
///
///
///
[HttpPost]
[Route("CheckAndInitVOLTAEdi")]
public DataResult CheckAndInitVOLTAEdi([FromBody] BookingOrClosingEDIOrderReq req)
{
return _invokeService.CheckAndInitVOLTAEdi(req);
}
///
/// 发送订舱、截单EDI
///
/// 订舱、截单EDI请求
/// 返回回执
[HttpPost]
[Route("SendBookingOrClosingEDI")]
public async Task> SendBookingOrClosingEDI([FromBody] BookingOrClosingEDIOrderReq req)
{
return await _invokeService.SendBookingOrClosingEDI(req);
}
///
/// 下载订舱、截单EDI
///
/// 订舱、截单EDI请求
/// 返回回执
[HttpPost]
[Route("DownloadBookingOrClosingEDI")]
[ProducesResponseType(typeof(FileResult), StatusCodes.Status200OK)]
public async Task DownloadBookingOrClosingEDI([FromBody] BookingOrClosingEDIOrderReq req)
{
var res = await _invokeService.DownloadBookingOrClosingEDI(req);
if (!res.Succeeded)
{
//return (IActionResult)await Task.FromResult(DataResult.Failed(res.Message));
throw new Exception(res.Message);
}
var path = res.Data.FilePath;
var fileName = res.Data.FileName;
byte[] byteArr = System.IO.File.ReadAllBytes(res.Data.FilePath);
string mimeType = "application/octet-stream";
return new FileContentResult(byteArr, mimeType)
{
FileDownloadName = fileName
};
}
///
/// 发送下货纸
///
/// 业务id
///
[HttpGet]
[Route("SendXHZ")]
public async Task SendXHZ([FromQuery] string id)
{
return await _invokeService.SendXHZ(id);
}
///
/// 船司电放提交
///
/// 订舱主键数组
/// 每单的处理提交结果
[HttpPost]
[Route("SubmitTelex")]
public async Task>> SubmitTelex([FromBody] IdModel req)
{
var res = await _invokeService.SubmitTelex(req);
return res;
}
///
/// 上传OCR附件
///
/// 文件信息
/// 业务附件请求实体 TypeCode = "other",TypeName = "其他"
///
[HttpPost]
[Route("UploadOcrFile")]
public async Task> UploadOcrFile(IFormFile file, [FromForm] OpFileReq req)
{
var res = _invokeService.UploadOcrFile(file, req);
return await res;
}
///
/// 获取文字
///
/// 文件名称
/// 缩放比例
/// x坐标
/// y坐标
/// 宽度
/// 高度
///
[HttpGet("GetOcrText")]
public async Task> GetOcrText([FromQuery] string fileName, float scale, int x, int y, int w, int h)
{
var config = await _commonService.GetConfigData("ocr_api_url");
if (!config.Succeeded)
{
return await Task.FromResult(DataResult.Failed("OCR接口地址未配置!"));
}
var url = config.Data;
if (!url.EndsWith("/"))
{
url += "/";
}
var postUrl = $"{url}pdf/getRegionText?fileName={fileName}&scale={scale}&x={x}&y={y}&w={w}&h={h}";
//var str = await $"{url}pdf/getRegionText?fileName={fileName}&scale={scale}&x={x}&y={y}&w={w}&h={h}"
//.PostAsStringAsync();
var str = RequestHelper.Post("", postUrl);
return await Task.FromResult(DataResult.Success(str)); ;
}
///
/// 获取图片
///
/// 文件名称
/// 缩放比例,默认为1.5
///
[HttpGet]
[Route("GetOcrImg")]
[ProducesResponseType(typeof(FileResult), StatusCodes.Status200OK)]
public async Task GetOcrImg([FromQuery] string fileName, float scale = 1.5f)
{
var config = await _commonService.GetConfigData("ocr_api_url");
//if (!config.Succeeded)
//{
// return await Task.FromResult(DataResult.Failed("OCR接口地址未配置!"));
//}
var url = config.Data;
if (!url.EndsWith("/"))
{
url += "/";
}
var postUrl = $"{url}pdf/getCanvasImage?fileName={fileName}&scale={scale}";
WebClient mywebclient = new WebClient();
byte[] byteArr = mywebclient.DownloadData(postUrl);
//byte[] byteArr = System.IO.File.ReadAllBytes(postUrl);
string mimeType = "application/octet-stream";
return new FileContentResult(byteArr, mimeType)
{
FileDownloadName = fileName
};
}
///
/// 海运出口规则引擎校验
///
/// 业务id
///
[HttpGet]
[Route("ExcuteRuleEngine")]
public async Task> ExcuteRuleEngine([FromQuery] string id)
{
return await _invokeService.ExcuteRuleEngine(id);
}
///
/// 订单及货运动态
///
///
///
[HttpPost]
[Route("GetBookingStatusLogList")]
public async Task>> GetBookingStatusLogList([FromBody] PageRequest request)
{
var res = await _invokeService.GetBookingStatusLogList(request);
return res;
}
///
/// 发送托书
///
///
///
[HttpPost]
[Route("SendShippingOrderEmail")]
public async Task> SendShippingOrderEmail([FromBody] SendShippingOrderReq req)
{
var res = await _invokeService.SendShippingOrderEmail(req);
return res;
}
}