You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
BookingHeChuan/Myshipping.Application/Service/TaskManagePlat/TaskManageVGMService.cs

228 lines
8.0 KiB
C#

9 months ago
using Furion.DynamicApiController;
using Furion.FriendlyException;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging.Abstractions;
9 months ago
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.Reflection.Metadata.Ecma335;
9 months ago
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
/// <summary>
/// VGM任务
/// </summary>
[ApiDescriptionSettings("Application", Name = "TaskManageVGM", Order = 10)]
public class TaskManageVGMService: ITaskManageVGMService, IDynamicApiController
{
private readonly SqlSugarRepository<TaskVGMInfo> _taskVGMInfoRepository;
private readonly SqlSugarRepository<TaskVGMCtnInfo> _taskVGMCtnInfoRepository;
private readonly SqlSugarRepository<TaskBaseInfo> _taskBaseRepository;
public TaskManageVGMService(SqlSugarRepository<TaskVGMInfo> taskVGMInfoRepository,
SqlSugarRepository<TaskVGMCtnInfo> taskVGMCtnInfoRepository,
SqlSugarRepository<TaskBaseInfo> taskBaseRepository)
{
_taskVGMInfoRepository = taskVGMInfoRepository;
_taskVGMCtnInfoRepository = taskVGMCtnInfoRepository;
_taskBaseRepository = taskBaseRepository;
}
#region 获取VGM成功回执详情
/// <summary>
/// 获取VGM成功回执详情
/// </summary>
/// <param name="pkId">BC主键</param>
/// <returns>返回回执</returns>
[HttpGet("/TaskManageVGM/GetVGMSubmissionInfo")]
9 months ago
public async Task<List<TaskVGMShowDto>> GetVGMSubmissionInfo(string pkId)
{
List<TaskVGMShowDto> list = new List<TaskVGMShowDto>();
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<TaskVGMShowDto>();
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成功回执详情
/// <summary>
/// 通过任务主键获取VGM成功回执详情
/// </summary>
/// <param name="taskPkId">VGM任务主键</param>
/// <returns>返回回执</returns>
[HttpGet("/TaskManageVGM/GetVGMSubmissionInfoByTaskId")]
9 months ago
public async Task<List<TaskVGMShowDto>> GetVGMSubmissionInfoByTaskId(string taskPkId)
{
List<TaskVGMShowDto> list = new List<TaskVGMShowDto>();
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<TaskVGMShowDto>();
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未提交详情
/// <summary>
/// 获取VGM未提交详情
/// </summary>
/// <param name="pkId">BC主键</param>
/// <returns>返回回执</returns>
[HttpGet("/TaskManageVGM/GetVGMMissingInfo")]
9 months ago
public async Task<List<TaskVGMShowDto>> GetVGMMissingInfo(string pkId)
{
List<TaskVGMShowDto> list = new List<TaskVGMShowDto>();
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)
9 months ago
{
list = CtnList.OrderBy(p => p.P_ID).ThenBy(p => p.CNTRNO).Select(p =>
{
TaskVGMShowDto model = vgmOrder.Adapt<TaskVGMShowDto>();
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未提交详情
/// <summary>
/// 通过任务主键获取VGM未提交详情
/// </summary>
/// <param name="taskPkId">VGM任务主键</param>
/// <returns>返回回执</returns>
[HttpGet("/TaskManageVGM/GetVGMMissingInfoByTaskId")]
9 months ago
public async Task<List<TaskVGMShowDto>> GetVGMMissingInfoByTaskId(string taskPkId)
{
List<TaskVGMShowDto> list = new List<TaskVGMShowDto>();
var taskBase = _taskBaseRepository.AsQueryable().First(a => a.PK_ID == taskPkId);
if (taskBase == null)
throw Oops.Oh($"任务主键{taskPkId}无法获取业务信息");
var vgmOrderList = _taskVGMInfoRepository.AsQueryable().Where(a => a.TASK_ID == taskBase.PK_ID).ToList();
9 months ago
if (vgmOrderList.Count == 0)
9 months ago
throw Oops.Oh($"任务主键{taskPkId}无法获取VGM信息");
var vgmPkList = vgmOrderList.Select(a => a.PK_ID).ToList();
9 months ago
var CtnList = _taskVGMCtnInfoRepository.AsQueryable()
.Where(a => vgmPkList.Contains(a.P_ID)).ToList();
9 months ago
if (CtnList.Count > 0)
{
vgmOrderList.ForEach(v => {
9 months ago
list.AddRange(CtnList.Where(p => p.P_ID == v.PK_ID).OrderBy(p => p.CNTRNO).Select(p =>
{
TaskVGMShowDto model = v.Adapt<TaskVGMShowDto>();
9 months ago
model.CntrNo = p.CNTRNO;
model.VGMWeight = p.VGM_WEIGHT;
model.VGMWeightMethod = p.VGM_METHOD;
model.VGMWeightUnit = p.VGM_WEIGHT_UNIT;
return model;
}).ToList());
});
9 months ago
}
return list;
}
#endregion
/// <summary>
/// 发送VGM未提交通知钉钉消息、邮件通知
/// </summary>
/// <param name="taskPkId"></param>
/// <returns></returns>
[HttpGet("/TaskManageVGM/SendVGMMissingNotice")]
public async Task<TaskManageOrderResultDto> SendVGMMissingNotice(string taskPkId)
{
/*
*/
//查询所有
return null;
}
public async Task<TaskManageOrderResultDto> SyncBookingOrder()
{
return null;
}
9 months ago
}
}