using Furion.DynamicApiController;
using Furion.FriendlyException;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using Myshipping.Application.Entity;
using Myshipping.Application.Service.TaskManagePlat.Interface;
using Myshipping.Core;
using MySqlX.XDevAPI.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
///
/// VGM任务
///
[ApiDescriptionSettings("Application", Name = "TaskManageVGM", Order = 10)]
public class TaskManageVGMService: ITaskManageVGMService, IDynamicApiController
{
private readonly SqlSugarRepository _taskVGMInfoRepository;
private readonly SqlSugarRepository _taskVGMCtnInfoRepository;
private readonly SqlSugarRepository _taskBaseRepository;
public TaskManageVGMService(SqlSugarRepository taskVGMInfoRepository,
SqlSugarRepository taskVGMCtnInfoRepository,
SqlSugarRepository taskBaseRepository)
{
_taskVGMInfoRepository = taskVGMInfoRepository;
_taskVGMCtnInfoRepository = taskVGMCtnInfoRepository;
_taskBaseRepository = taskBaseRepository;
}
#region 获取VGM成功回执详情
///
/// 获取VGM成功回执详情
///
/// BC主键
/// 返回回执
[HttpGet("/BookingMSKAPI/GetVGMSubmissionInfo")]
public async Task> GetVGMSubmissionInfo(string pkId)
{
List list = new List();
var vgmOrder = _taskVGMInfoRepository.AsQueryable().First(a => a.PK_ID == pkId);
if (vgmOrder == null)
throw Oops.Oh($"VGM主键{pkId}无法获取业务信息");
var CtnList = _taskVGMCtnInfoRepository.AsQueryable()
.Where(a => a.P_ID == pkId).ToList();
if (CtnList.Count > 0)
{
list = CtnList.OrderBy(p => p.P_ID).ThenBy(p => p.CNTRNO).Select(p =>
{
TaskVGMShowDto model = vgmOrder.Adapt();
model.CntrNo = p.CNTRNO;
model.VGMWeight = p.VGM_WEIGHT;
model.VGMWeightMethod = p.VGM_METHOD;
model.VGMWeightUnit = p.VGM_WEIGHT_UNIT;
return model;
}).ToList();
}
return list;
}
#endregion
#region 通过任务主键获取VGM成功回执详情
///
/// 通过任务主键获取VGM成功回执详情
///
/// VGM任务主键
/// 返回回执
[HttpGet("/BookingMSKAPI/GetVGMSubmissionInfoByTaskId")]
public async Task> GetVGMSubmissionInfoByTaskId(string taskPkId)
{
List list = new List();
var taskBase = _taskBaseRepository.AsQueryable().First(a => a.PK_ID == taskPkId);
if (taskBase == null)
throw Oops.Oh($"任务主键{taskPkId}无法获取业务信息");
var vgmOrder = _taskVGMInfoRepository.AsQueryable().First(a => a.TASK_ID == taskBase.PK_ID);
if (vgmOrder == null)
throw Oops.Oh($"任务主键{taskPkId}无法获取VGM信息");
var CtnList = _taskVGMCtnInfoRepository.AsQueryable()
.Where(a => a.P_ID == vgmOrder.PK_ID).ToList();
if (CtnList.Count > 0)
{
list = CtnList.OrderBy(p => p.P_ID).ThenBy(p => p.CNTRNO).Select(p =>
{
TaskVGMShowDto model = vgmOrder.Adapt();
model.CntrNo = p.CNTRNO;
model.VGMWeight = p.VGM_WEIGHT;
model.VGMWeightMethod = p.VGM_METHOD;
model.VGMWeightUnit = p.VGM_WEIGHT_UNIT;
return model;
}).ToList();
}
return list;
}
#endregion
#region 获取VGM未提交详情
///
/// 获取VGM未提交详情
///
/// BC主键
/// 返回回执
[HttpGet("/BookingMSKAPI/GetVGMMissingInfo")]
public async Task> GetVGMMissingInfo(string pkId)
{
List list = new List();
var vgmOrder = _taskVGMInfoRepository.AsQueryable().First(a => a.PK_ID == pkId);
if (vgmOrder == null)
throw Oops.Oh($"VGM主键{pkId}无法获取业务信息");
var CtnList = _taskVGMCtnInfoRepository.AsQueryable()
.Where(a => a.P_ID == pkId).ToList();
if (CtnList.Count > 0)
{
list = CtnList.OrderBy(p => p.P_ID).ThenBy(p => p.CNTRNO).Select(p =>
{
TaskVGMShowDto model = vgmOrder.Adapt();
model.CntrNo = p.CNTRNO;
model.VGMWeight = p.VGM_WEIGHT;
model.VGMWeightMethod = p.VGM_METHOD;
model.VGMWeightUnit = p.VGM_WEIGHT_UNIT;
return model;
}).ToList();
}
return list;
}
#endregion
#region 通过任务主键获取VGM未提交详情
///
/// 通过任务主键获取VGM未提交详情
///
/// VGM任务主键
/// 返回回执
[HttpGet("/BookingMSKAPI/GetVGMMissingInfoByTaskId")]
public async Task> GetVGMMissingInfoByTaskId(string taskPkId)
{
List list = new List();
var taskBase = _taskBaseRepository.AsQueryable().First(a => a.PK_ID == taskPkId);
if (taskBase == null)
throw Oops.Oh($"任务主键{taskPkId}无法获取业务信息");
var vgmOrder = _taskVGMInfoRepository.AsQueryable().First(a => a.TASK_ID == taskBase.PK_ID);
if (vgmOrder == null)
throw Oops.Oh($"任务主键{taskPkId}无法获取VGM信息");
var CtnList = _taskVGMCtnInfoRepository.AsQueryable()
.Where(a => a.P_ID == vgmOrder.PK_ID).ToList();
if (CtnList.Count > 0)
{
list = CtnList.OrderBy(p => p.P_ID).ThenBy(p => p.CNTRNO).Select(p =>
{
TaskVGMShowDto model = vgmOrder.Adapt();
model.CntrNo = p.CNTRNO;
model.VGMWeight = p.VGM_WEIGHT;
model.VGMWeightMethod = p.VGM_METHOD;
model.VGMWeightUnit = p.VGM_WEIGHT_UNIT;
return model;
}).ToList();
}
return list;
}
#endregion
}
}