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

218 lines
7.8 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using Furion.DynamicApiController;
using Furion.FriendlyException;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging.Abstractions;
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
{
/// <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")]
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")]
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")]
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)
{
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")]
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();
if (vgmOrderList.Count == 0)
throw Oops.Oh($"任务主键{taskPkId}无法获取VGM信息");
var vgmPkList = vgmOrderList.Select(a => a.PK_ID).ToList();
var CtnList = _taskVGMCtnInfoRepository.AsQueryable()
.Where(a => vgmPkList.Contains(a.P_ID)).ToList();
if (CtnList.Count > 0)
{
vgmOrderList.ForEach(v => {
list.AddRange(CtnList.Where(p => p.P_ID == v.PK_ID).OrderBy(p => p.CNTRNO).Select(p =>
{
TaskVGMShowDto model = v.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
/// <summary>
/// 发送VGM未提交通知钉钉消息、邮件通知
/// </summary>
/// <param name="taskPkId"></param>
/// <returns></returns>
[HttpGet("/TaskManageVGM/SendVGMMissingNotice")]
public async Task<TaskManageOrderResultDto> SendVGMMissingNotice(string taskPkId)
{
//查询所有
return null;
}
}
}