jianghaiqing 4 months ago
commit 27767265af

@ -1479,7 +1479,7 @@ public static class MultiLanguageConst
#endregion #endregion
#region 关联任务 #region 关联任务
[Description("此类型的任务已存在")] [Description("此任务已存在,请勿重复提交")]
public const string TaskExists = "Task_Exists"; public const string TaskExists = "Task_Exists";
[Description("此任务已完成")] [Description("此任务已完成")]
public const string TaskCompleted = "Task_Completed"; public const string TaskCompleted = "Task_Completed";

@ -1,4 +1,5 @@
using System; using SqlSugar;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Linq; using System.Linq;
@ -192,5 +193,41 @@ namespace DS.WMS.Core.Op.Dtos
/// CNPTNo /// CNPTNo
/// </summary> /// </summary>
public string CNPTNo { get; set; } public string CNPTNo { get; set; }
/// <summary>
/// 装运方式代码 整箱、拼箱单票、拼箱主票、拼箱分票代码
/// </summary>
public string BLTypeCode { get; set; }
/// <summary>
/// Desc:结算方式代码
/// </summary>
public string StlCode { get; set; }
/// <summary>
/// Desc:贸易方式代码
/// </summary>
public string TermDeliveryCdoe { get; set; }
/// <summary>
/// Desc:贸易条款代码
/// </summary>
public string TradeTermCode { get; set; }
/// <summary>
/// 签单方式代码 t_code_issutype
/// </summary>
public string IssueTypeCode { get; set; }
/// <summary>
/// Desc:MBL付费方式代码 t_code_frt
/// </summary>
public string MBLFrtCode { get; set; }
/// <summary>
/// 运输条款代码 CY-CY t_code_service
/// </summary>
public string ServiceCode { get; set; }
} }
} }

@ -193,5 +193,40 @@ namespace DS.WMS.Core.Op.Dtos
/// CNPTNo /// CNPTNo
/// </summary> /// </summary>
public string CNPTNo { get; set; } public string CNPTNo { get; set; }
/// <summary>
/// 装运方式代码 整箱、拼箱单票、拼箱主票、拼箱分票代码
/// </summary>
public string BLTypeCode { get; set; }
/// <summary>
/// Desc:结算方式代码
/// </summary>
public string StlCode { get; set; }
/// <summary>
/// Desc:贸易方式代码
/// </summary>
public string TermDeliveryCdoe { get; set; }
/// <summary>
/// Desc:贸易条款代码
/// </summary>
public string TradeTermCode { get; set; }
/// <summary>
/// 签单方式代码 t_code_issutype
/// </summary>
public string IssueTypeCode { get; set; }
/// <summary>
/// Desc:MBL付费方式代码 t_code_frt
/// </summary>
public string MBLFrtCode { get; set; }
/// <summary>
/// 运输条款代码 CY-CY t_code_service
/// </summary>
public string ServiceCode { get; set; }
} }
} }

@ -20,7 +20,7 @@ namespace DS.WMS.Core.Op.Dtos.TaskInteraction
/// </summary> /// </summary>
public BusinessType BusinessType { get; set; } public BusinessType BusinessType { get; set; }
TaskBaseTypeEnum _defaultTaskType = TaskBaseTypeEnum.NOT_SPECIFIED; static readonly TaskBaseTypeEnum _defaultTaskType = TaskBaseTypeEnum.NOT_SPECIFIED;
/// <summary> /// <summary>
/// 任务类型 /// 任务类型
/// </summary> /// </summary>

@ -86,7 +86,7 @@ public class SeaExport : BaseOrgModel<long>
/// <summary> /// <summary>
/// 装运方式 整箱、拼箱单票、拼箱主票、拼箱分票 /// 装运方式 整箱、拼箱单票、拼箱主票、拼箱分票
/// </summary> /// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "装运方式", IsNullable = false, Length = 8)] [SqlSugar.SugarColumn(ColumnDescription = "装运方式", IsNullable = false, Length = 30)]
public string BLType { get; set; } public string BLType { get; set; }
/// <summary> /// <summary>
@ -1076,7 +1076,7 @@ public class SeaExport : BaseOrgModel<long>
/// <summary> /// <summary>
/// Desc:贸易方式 /// Desc:贸易方式
/// </summary> /// </summary>
[SugarColumn(ColumnDescription = "贸易方式", Length = 10, IsNullable = true)] [SugarColumn(ColumnDescription = "贸易方式", Length = 30, IsNullable = true)]
public string TermDelivery { get; set; } public string TermDelivery { get; set; }
/// <summary> /// <summary>
@ -1388,4 +1388,48 @@ public class SeaExport : BaseOrgModel<long>
/// </summary> /// </summary>
[SugarColumn(ColumnDescription = "申请箱使", IsNullable = true, Length = 100)] [SugarColumn(ColumnDescription = "申请箱使", IsNullable = true, Length = 100)]
public string ApplyCtnRemark { get; set; } public string ApplyCtnRemark { get; set; }
/// <summary>
/// 装运方式代码 整箱、拼箱单票、拼箱主票、拼箱分票代码
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "装运方式代码", IsNullable = false, Length = 30)]
public string BLTypeCode { get; set; }
/// <summary>
/// Desc:结算方式代码
/// </summary>
[SugarColumn(ColumnDescription = "结算方式代码", IsNullable = true, Length = 30)]
public string StlCode { get; set; }
/// <summary>
/// Desc:贸易方式代码
/// </summary>
[SugarColumn(ColumnDescription = "贸易方式代码", Length = 30, IsNullable = true)]
public string TermDeliveryCdoe { get; set; }
/// <summary>
/// Desc:贸易条款代码
/// </summary>
[SugarColumn(ColumnDescription = "贸易条款代码", Length = 30, IsNullable = true)]
public string TradeTermCode { get; set; }
/// <summary>
/// 签单方式代码 t_code_issutype
/// </summary>
[SugarColumn(ColumnDescription = "签单方式代码", IsNullable = true, Length = 30)]
public string IssueTypeCode { get; set; }
/// <summary>
/// Desc:MBL付费方式代码 t_code_frt
/// </summary>
[SugarColumn(ColumnDescription = "MBL付费方式代码", IsNullable = true, Length = 30)]
public string MBLFrtCode { get; set; }
/// <summary>
/// 运输条款代码 CY-CY t_code_service
/// </summary>
[SugarColumn(ColumnDescription = "运输条款代码", IsNullable = true, Length = 30)]
public string ServiceCode { get; set; }
} }

@ -211,4 +211,12 @@ public interface ISeaExportService
/// <param name="Ids"></param> /// <param name="Ids"></param>
/// <returns></returns> /// <returns></returns>
public Task<DataResult<string>> RefreshYGT(long[] Ids); public Task<DataResult<string>> RefreshYGT(long[] Ids);
/// <summary>
/// 打印保函
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public Task<DataResult> PrintShippingOrderLetterPDF(string id);
} }

@ -28,6 +28,50 @@ namespace DS.WMS.Core.Op.Method
/// </summary> /// </summary>
public partial class SeaExportService public partial class SeaExportService
{ {
/// <summary>
/// 打印保函
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<DataResult> PrintShippingOrderLetterPDF(string id)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var book = await tenantDb.Queryable<SeaExport>().FirstAsync(x => x.Id == long.Parse(id));
if (book == null)
{
return await Task.FromResult(DataResult.Failed("未找到订舱数据"));
}
var template = await db.Queryable<SysPrintTemplate>().FirstAsync(x => x.TemplateCode == "bill_of_letter" && x.CarrierId == book.CarrierId);
if (template == null)
{
return await Task.FromResult(DataResult.Failed("未找到当前船公司保函模板,模板代码:bill_of_letter"));
}
var url = AppSetting.Configuration["PrintService:LocalPrintUrl"];
if (url.IsNull())
return await Task.FromResult(DataResult.Failed("未配置本地打印地址"));
var req = new Module.PrintModule.OpenJsonPrintReq
{
TemplateId = template.Id,
PrintType = "1",
JsonDataStr = JsonConvert.SerializeObject(book)
};
var token = user.GetToken();
var res = await RequestHelper.PostJosnAsyncByToken(url, req.ToJson(), token);
//var result = JsonConvert.DeserializeObject<DataResult>(res);
var result = JObject.Parse(res);
if (result.GetBooleanValue("succeeded"))
{
return await Task.FromResult(DataResult.Successed("打印保函成功", result.GetStringValue("data"), MultiLanguageConst.DataQuerySuccess));
}
else
{
return await Task.FromResult(DataResult.Failed(result.GetStringValue("message")));
}
}
/// <summary> /// <summary>
/// 打印托书 /// 打印托书
/// </summary> /// </summary>
@ -51,11 +95,12 @@ namespace DS.WMS.Core.Op.Method
if (url.IsNull()) if (url.IsNull())
return await Task.FromResult(DataResult.Failed("未配置本地打印地址")); return await Task.FromResult(DataResult.Failed("未配置本地打印地址"));
var req = new Module.PrintModule.OpenJsonPrintReq var req = new Module.PrintModule.OpenJsonPrintReq
{ {
TemplateId = template.Id, TemplateId = template.Id,
PrintType = "1", PrintType = "1",
JsonDataStr = "" JsonDataStr = JsonConvert.SerializeObject(book)
}; };
var token = user.GetToken(); var token = user.GetToken();
var res = await RequestHelper.PostJosnAsyncByToken(url, req.ToJson(),token); var res = await RequestHelper.PostJosnAsyncByToken(url, req.ToJson(),token);

@ -85,9 +85,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
/// <returns></returns> /// <returns></returns>
protected virtual async Task<bool> EnsureModuleAuthorized() protected virtual async Task<bool> EnsureModuleAuthorized()
{ {
//if (!await Db.Queryable<SysPermissionTenant>().AnyAsync(x => x.PermissionId == PERMISSION_ID))
// return false;
long tid = long.Parse(User.TenantId); long tid = long.Parse(User.TenantId);
var authStr = await Db.Queryable<SysTenantPermissionAuth>().Where(x => x.PermissionId == PERMISSION_ID && x.TenantId == tid && var authStr = await Db.Queryable<SysTenantPermissionAuth>().Where(x => x.PermissionId == PERMISSION_ID && x.TenantId == tid &&
SqlFunc.Subqueryable<SysPermissionTenant>().Where(spt => spt.PermissionId == x.PermissionId).Any()) SqlFunc.Subqueryable<SysPermissionTenant>().Where(spt => spt.PermissionId == x.PermissionId).Any())

@ -163,6 +163,11 @@ namespace DS.WMS.Core.Sys.Method
/// 签单方式映射 /// 签单方式映射
/// </summary> /// </summary>
[Description("签单方式映射")] [Description("签单方式映射")]
CommonMappingIssueType CommonMappingIssueType,
/// <summary>
/// 任务分配设置
/// </summary>
[Description("任务分配设置")]
TaskAllocationtSet,
} }
} }

@ -55,6 +55,76 @@ namespace DS.WMS.Core.TaskPlat.Dtos
public List<TaskTypeInfoDto> DriverTaskTypeList { get; set; } public List<TaskTypeInfoDto> DriverTaskTypeList { get; set; }
public List<TaskTypeInfoDto> DispatcherTaskTypeList { get; set; } public List<TaskTypeInfoDto> DispatcherTaskTypeList { get; set; }
} }
public class TaskAllocationtSetDto
{
public long Id { get; set; }
/// <summary>
/// 任务类型编码
/// </summary>
public string TaskTypeCode { get; set; }
/// <summary>
/// 任务类型名称
/// </summary>
public string TaskTypeName { get; set; }
/// <summary>
/// 船公司ID
/// </summary>
public long? CarrierId { get; set; }
/// <summary>
/// 船公司代码
/// </summary>
public string? CarrierCode { get; set; }
/// <summary>
/// 船公司
/// </summary>
public string? Carrier { get; set; }
/// <summary>
/// 是否分配至操作
/// </summary>
public bool IsAllotOperator { get; set; }
/// <summary>
/// 是否分配至单证
/// </summary>
public bool IsAllotVouchingClerk { get; set; }
/// <summary>
/// 是否分配至销售
/// </summary>
public bool IsAllotSale { get; set; }
/// <summary>
/// 是否分配至客服
/// </summary>
public bool IsAllotCustomerService { get; set; }
///// <summary>
///// 是否分配至报关员
///// </summary>
//public bool IsAllotCustom { get; set; }
///// <summary>
///// 是否分配至财务
///// </summary>
//public bool IsAllotFinancialStaff { get; set; }
///// <summary>
///// 是否分配至司机
///// </summary>
//public bool IsAllotDriver { get; set; }
///// <summary>
///// 是否分配至派车调度人员
///// </summary>
//public bool IsAllotDispatcher { get; set; }
}
public class TaskTypeInfoDto public class TaskTypeInfoDto
{ {
/// <summary> /// <summary>

@ -57,34 +57,35 @@ namespace DS.WMS.Core.TaskPlat.Entity
[SugarColumn(ColumnDescription = "是否分配至销售", IsNullable = false)] [SugarColumn(ColumnDescription = "是否分配至销售", IsNullable = false)]
public bool IsAllotSale { get; set; } public bool IsAllotSale { get; set; }
/// <summary>
/// 是否分配至报关员
/// </summary>
[SugarColumn(ColumnDescription = "是否分配至报关员", IsNullable = false)]
public bool IsAllotCustom { get; set; }
/// <summary>
/// 是否分配至财务
/// </summary>
[SugarColumn(ColumnDescription = "是否分配至财务", IsNullable = false)]
public bool IsAllotFinancialStaff { get; set; }
/// <summary> /// <summary>
/// 是否分配至客服 /// 是否分配至客服
/// </summary> /// </summary>
[SugarColumn(ColumnDescription = "是否分配至客服", IsNullable = false)] [SugarColumn(ColumnDescription = "是否分配至客服", IsNullable = false)]
public bool IsAllotCustomerService { get; set; } public bool IsAllotCustomerService { get; set; }
/// <summary> ///// <summary>
/// 是否分配至司机 ///// 是否分配至报关员
/// </summary> ///// </summary>
[SugarColumn(ColumnDescription = "是否分配至司机", IsNullable = false)] //[SugarColumn(ColumnDescription = "是否分配至报关员", IsNullable = false)]
public bool IsAllotDriver { get; set; } //public bool IsAllotCustom { get; set; }
/// <summary> ///// <summary>
/// 是否分配至派车调度人员 ///// 是否分配至财务
/// </summary> ///// </summary>
[SugarColumn(ColumnDescription = "是否分配至派车调度人员", IsNullable = false)] //[SugarColumn(ColumnDescription = "是否分配至财务", IsNullable = false)]
public bool IsAllotDispatcher { get; set; } //public bool IsAllotFinancialStaff { get; set; }
///// <summary>
///// 是否分配至司机
///// </summary>
//[SugarColumn(ColumnDescription = "是否分配至司机", IsNullable = false)]
//public bool IsAllotDriver { get; set; }
///// <summary>
///// 是否分配至派车调度人员
///// </summary>
//[SugarColumn(ColumnDescription = "是否分配至派车调度人员", IsNullable = false)]
//public bool IsAllotDispatcher { get; set; }
} }
} }

@ -19,5 +19,12 @@ namespace DS.WMS.Core.TaskPlat.Interface
/// 保存任务分配设置 /// 保存任务分配设置
/// </summary> /// </summary>
Task<DataResult> Save(TaskAllocationtSetSaveDto saveDto); Task<DataResult> Save(TaskAllocationtSetSaveDto saveDto);
/// <summary>
/// 获取任务分配数据
/// </summary>
/// <param name="isFromCache">是否从缓存提取 true-从缓存读取 false-从数据库读取</param>
/// <returns>返回任务分配数据列表</returns>
Task<DataResult<List<TaskAllocationtSetDto>>> GetAllList(bool isFromCache = true);
} }
} }

@ -1,4 +1,5 @@
using DS.WMS.Core.TaskPlat.Dtos; using DS.Module.Core;
using DS.WMS.Core.TaskPlat.Dtos;
using DS.WMS.Core.TaskPlat.Entity; using DS.WMS.Core.TaskPlat.Entity;
using System.Linq.Expressions; using System.Linq.Expressions;
@ -29,5 +30,6 @@ namespace DS.WMS.Core.TaskPlat.Interface
/// <param name="taskId">任务Id</param> /// <param name="taskId">任务Id</param>
/// <param name="fileCategory">附件分类代码</param> /// <param name="fileCategory">附件分类代码</param>
Task<(string fileFullPath, string fileName)> GetTaskFileInfo(long taskId, string fileCategory); Task<(string fileFullPath, string fileName)> GetTaskFileInfo(long taskId, string fileCategory);
Task<DataResult<MatchTaskResultDto>> MatchTask(List<long>? taskIdList);
} }
} }

@ -1,11 +1,14 @@
using DS.Module.Core; using DS.Module.Core;
using DS.Module.SqlSugar; using DS.Module.SqlSugar;
using DS.Module.UserModule; using DS.Module.UserModule;
using DS.WMS.Core.Sys.Interface;
using DS.WMS.Core.Sys.Method;
using DS.WMS.Core.TaskPlat.Dtos; using DS.WMS.Core.TaskPlat.Dtos;
using DS.WMS.Core.TaskPlat.Entity; using DS.WMS.Core.TaskPlat.Entity;
using DS.WMS.Core.TaskPlat.Interface; using DS.WMS.Core.TaskPlat.Interface;
using LanguageExt.Pipes; using LanguageExt.Pipes;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using SqlSugar; using SqlSugar;
@ -19,14 +22,17 @@ namespace DS.WMS.Core.TaskPlat.Method
private readonly IUser user; private readonly IUser user;
private readonly ILogger<TaskManageBCService> logger; private readonly ILogger<TaskManageBCService> logger;
private readonly ISaasDbService saasDbService; private readonly ISaasDbService saasDbService;
private readonly ISysCacheService sysCacheService;
public TaskAllocationService(IUser user, public TaskAllocationService(IUser user,
ILogger<TaskManageBCService> logger, ILogger<TaskManageBCService> logger,
ISaasDbService saasDbService) ISaasDbService saasDbService,
ISysCacheService sysCacheService)
{ {
this.user = user; this.user = user;
this.logger = logger; this.logger = logger;
this.saasDbService = saasDbService; this.saasDbService = saasDbService;
this.sysCacheService = sysCacheService;
} }
/// <summary> /// <summary>
/// 获取任务分配列表 /// 获取任务分配列表
@ -38,14 +44,10 @@ namespace DS.WMS.Core.TaskPlat.Method
var list = await tenantDb.Queryable<TaskAllocationtSet>() var list = await tenantDb.Queryable<TaskAllocationtSet>()
.Where(x => x.CarrierId == carrierId && .Where(x => x.CarrierId == carrierId &&
(x.IsAllotCustom (x.IsAllotCustomerService
|| x.IsAllotCustomerService
|| x.IsAllotDispatcher
|| x.IsAllotOperator || x.IsAllotOperator
|| x.IsAllotSale || x.IsAllotSale
|| x.IsAllotVouchingClerk || x.IsAllotVouchingClerk))
|| x.IsAllotFinancialStaff
|| x.IsAllotDriver))
.ToListAsync(); .ToListAsync();
Func<TaskAllocationtSet, TaskTypeInfoDto> selector = x => new TaskTypeInfoDto() { TaskTypeCode = x.TaskTypeCode, TaskTypeName = x.TaskTypeName }; Func<TaskAllocationtSet, TaskTypeInfoDto> selector = x => new TaskTypeInfoDto() { TaskTypeCode = x.TaskTypeCode, TaskTypeName = x.TaskTypeName };
@ -54,11 +56,7 @@ namespace DS.WMS.Core.TaskPlat.Method
OperatorTaskTypeList = list.Where(x => x.IsAllotOperator).Select(selector).ToList(), OperatorTaskTypeList = list.Where(x => x.IsAllotOperator).Select(selector).ToList(),
VouchingClerkTaskTypeList = list.Where(x => x.IsAllotVouchingClerk).Select(selector).ToList(), VouchingClerkTaskTypeList = list.Where(x => x.IsAllotVouchingClerk).Select(selector).ToList(),
SaleTaskTypeList = list.Where(x => x.IsAllotSale).Select(selector).ToList(), SaleTaskTypeList = list.Where(x => x.IsAllotSale).Select(selector).ToList(),
CustomTaskTypeList = list.Where(x => x.IsAllotCustom).Select(selector).ToList(),
FinancialStaffTaskTypeList = list.Where(x => x.IsAllotFinancialStaff).Select(selector).ToList(),
CustomerServiceTaskTypeList = list.Where(x => x.IsAllotCustomerService).Select(selector).ToList(), CustomerServiceTaskTypeList = list.Where(x => x.IsAllotCustomerService).Select(selector).ToList(),
DriverTaskTypeList = list.Where(x => x.IsAllotDriver).Select(selector).ToList(),
DispatcherTaskTypeList = list.Where(x => x.IsAllotDispatcher).Select(selector).ToList(),
}; };
//if (carrierId != null && list.Count != 0) //if (carrierId != null && list.Count != 0)
//{ //{
@ -112,11 +110,13 @@ namespace DS.WMS.Core.TaskPlat.Method
"Operator" => nameof(TaskAllocationtSet.IsAllotOperator), "Operator" => nameof(TaskAllocationtSet.IsAllotOperator),
"VouchingClerk" => nameof(TaskAllocationtSet.IsAllotVouchingClerk), "VouchingClerk" => nameof(TaskAllocationtSet.IsAllotVouchingClerk),
"Sale" => nameof(TaskAllocationtSet.IsAllotSale), "Sale" => nameof(TaskAllocationtSet.IsAllotSale),
"Custom" => nameof(TaskAllocationtSet.IsAllotCustom),
"FinancialStaff" => nameof(TaskAllocationtSet.IsAllotFinancialStaff),
"CustomerService" => nameof(TaskAllocationtSet.IsAllotCustomerService), "CustomerService" => nameof(TaskAllocationtSet.IsAllotCustomerService),
"Driver" => nameof(TaskAllocationtSet.IsAllotDriver),
"Dispatcher" => nameof(TaskAllocationtSet.IsAllotDispatcher), //"Custom" => nameof(TaskAllocationtSet.IsAllotCustom),
//"FinancialStaff" => nameof(TaskAllocationtSet.IsAllotFinancialStaff),
//"Driver" => nameof(TaskAllocationtSet.IsAllotDriver),
//"Dispatcher" => nameof(TaskAllocationtSet.IsAllotDispatcher),
_ => throw new NotImplementedException(), _ => throw new NotImplementedException(),
}; };
@ -165,6 +165,9 @@ namespace DS.WMS.Core.TaskPlat.Method
} }
await tenantDb.Ado.CommitTranAsync(); await tenantDb.Ado.CommitTranAsync();
await sysCacheService.RemoveCache(SysCacheCategoryEnum.TaskAllocationtSet, "DS8");
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -174,5 +177,45 @@ namespace DS.WMS.Core.TaskPlat.Method
} }
return DataResult.Successed(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.DataUpdateSuccess))); return DataResult.Successed(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.DataUpdateSuccess)));
} }
/// <summary>
/// 获取任务分配数据
/// </summary>
/// <param name="isFromCache">是否从缓存提取 true-从缓存读取 false-从数据库读取</param>
/// <returns>返回任务分配数据列表</returns>
public async Task<DataResult<List<TaskAllocationtSetDto>>> GetAllList(bool isFromCache = true)
{
List<TaskAllocationtSetDto> list = new List<TaskAllocationtSetDto>();
bool isLoad = false;
if (isFromCache)
{
var rlt = await sysCacheService.GetAllCommonCodeFromCache<TaskAllocationtSetDto>(SysCacheCategoryEnum.TaskAllocationtSet, "DS8");
if (rlt.Succeeded)
return rlt;
isLoad = true;
}
var tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
list = await tenantDb.Queryable<TaskAllocationtSet>()
.Select<TaskAllocationtSetDto>()
.ToListAsync();
if (list.Count > 0)
{
if (isLoad)
{
await sysCacheService.SetCommonCode(JsonConvert.SerializeObject(list), Sys.Method.SysCacheCategoryEnum.TaskAllocationtSet, "DS8");
}
return DataResult<List<TaskAllocationtSetDto>>.Success(list);
}
return DataResult<List<TaskAllocationtSetDto>>.FailedData(list);
}
} }
} }

@ -1,16 +1,19 @@
using DS.Module.Core; using DS.Module.Core;
using DS.Module.SqlSugar; using DS.Module.SqlSugar;
using DS.Module.UserModule; using DS.Module.UserModule;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.TaskPlat.Dtos; using DS.WMS.Core.TaskPlat.Dtos;
using DS.WMS.Core.TaskPlat.Entity; using DS.WMS.Core.TaskPlat.Entity;
using DS.WMS.Core.TaskPlat.Interface; using DS.WMS.Core.TaskPlat.Interface;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using SqlSugar; using SqlSugar;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Web; using System.Web;
//using static DS.WMS.Core.TaskPlat.Dtos.MatchTaskResultDto;
namespace DS.WMS.Core.TaskPlat.Method namespace DS.WMS.Core.TaskPlat.Method
{ {
@ -19,12 +22,16 @@ namespace DS.WMS.Core.TaskPlat.Method
/// </summary> /// </summary>
public class TaskManageBaseService<T> : ITaskManageBaseService public class TaskManageBaseService<T> : ITaskManageBaseService
{ {
// 实例化时构建
protected readonly IUser user; protected readonly IUser user;
protected readonly ILogger<T> logger; protected readonly ILogger<T> logger;
protected readonly ISaasDbService saasDbService; protected readonly ISaasDbService saasDbService;
protected readonly IServiceProvider serviceProvider; protected readonly IServiceProvider serviceProvider;
protected readonly IWebHostEnvironment environment; protected readonly IWebHostEnvironment environment;
// 按需构建
private Lazy<ITaskAllocationService> allocationService;
public TaskManageBaseService(IUser user, public TaskManageBaseService(IUser user,
ILogger<T> logger, ILogger<T> logger,
ISaasDbService saasDbService, ISaasDbService saasDbService,
@ -36,6 +43,8 @@ namespace DS.WMS.Core.TaskPlat.Method
this.saasDbService = saasDbService; this.saasDbService = saasDbService;
this.serviceProvider = serviceProvider; this.serviceProvider = serviceProvider;
this.environment = environment; this.environment = environment;
allocationService = new Lazy<ITaskAllocationService>(serviceProvider.GetRequiredService<ITaskAllocationService>());
} }
/// <summary> /// <summary>
@ -300,5 +309,163 @@ namespace DS.WMS.Core.TaskPlat.Method
return (fileFullPath, fileName); return (fileFullPath, fileName);
//return (new FileStream(fileFullPath, FileMode.Open), fileName); //return (new FileStream(fileFullPath, FileMode.Open), fileName);
} }
/// <summary>
/// 根据订单及配置,将所有或指定的公共任务匹配到个人
/// </summary>
/// <param name="taskIdList">任务Id列表当传入时则只匹配列表中指定的任务</param>
/// <returns>涉及当前登陆人的匹配结果</returns>
public async Task<DataResult<MatchTaskResultDto>> MatchTask(List<long>? taskIdList)
{
MatchTaskResultDto result = new MatchTaskResultDto();
var tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
var taskList = await tenantDb.Queryable<TaskBaseInfo>()
.Where(x => x.IS_PUBLIC == 1
&& x.STATUS == TaskStatusEnum.Create.ToString()
&& !string.IsNullOrEmpty(x.MBL_NO))
.WhereIF(taskIdList != null && taskIdList.Count > 0, x => taskIdList!.Contains(x.Id))
.ToListAsync(x => new TaskBaseInfo
{
Id = x.Id,
MBL_NO = x.MBL_NO,
TASK_TYPE = x.TASK_TYPE,
TASK_TYPE_NAME = x.TASK_TYPE_NAME,
CARRIER_ID = x.CARRIER_ID,
});
var allotSetList = await allocationService.Value.GetAllList();
if (!allotSetList.Succeeded || allotSetList.Data?.Any() != true)
{
return DataResult<MatchTaskResultDto>.Success("操作成功!", result, MultiLanguageConst.DataUpdateSuccess);
}
// 需要查询的订单的提单号的集合,用于一次性将需要查询的订单查询出来;
List<string> waitQuerySeaExportWithMblnoList = new();
// 后续如果需要查询舱位可以再补充字段如List<string> waitQuerySlotWithMblnoList = new();
List<(TaskBaseInfo task, TaskAllocationtSetDto allotSet, List<RecvUserInfo> allotUserList)> allotData = new();
foreach (var item in taskList)
{
// 查找配置规则
var targetAllotSet = allotSetList.Data.Where(x => x.TaskTypeCode == item.TASK_TYPE && x.CarrierCode == item.CARRIER_ID).OrderBy(x => x.Id).FirstOrDefault();
if (targetAllotSet == null)
{
targetAllotSet = allotSetList.Data.Where(x => x.TaskTypeCode == item.TASK_TYPE).OrderBy(x => x.Id).FirstOrDefault();
// 如果某种任务没有配置接收对象,则该任务跳过分配
if (targetAllotSet == null) continue;
}
allotData.Add((item, targetAllotSet!, new List<RecvUserInfo>()));
// 如果配置的下面四种接收对象,则需要查询订单
if (targetAllotSet.IsAllotCustomerService
|| targetAllotSet.IsAllotSale
|| targetAllotSet.IsAllotOperator
|| targetAllotSet.IsAllotVouchingClerk)
{
waitQuerySeaExportWithMblnoList.Add(item.MBL_NO!);
}
}
// 查出涉及到的订单
var seaExportList = await tenantDb.Queryable<SeaExport>()
.Where(x => waitQuerySeaExportWithMblnoList.Contains(x.MBLNO) && x.ParentId == 0)
.Select(x => new
{
x.Id,
x.MBLNO,
x.OperatorId,
x.OperatorName,
x.Doc,
x.DocName,
x.SaleId,
x.Sale,
x.CustomerService,
x.CustomerServiceName,
x.ForeignCustomerService,
x.ForeignCustomerServiceName
}).ToListAsync();
foreach (var item in allotData)
{
// 如果某条任务配置的接收目标为销售、操作、单证、客服中的一项,则需要查订单
if (item.allotSet.IsAllotCustomerService
|| item.allotSet.IsAllotOperator
|| item.allotSet.IsAllotSale
|| item.allotSet.IsAllotVouchingClerk)
{
var order = seaExportList.FirstOrDefault(x => x.MBLNO == item.task.MBL_NO);
if (order == null)
{
continue;
}
/*
* Operator=OperatorId+OperatorName
* VouchingClerk=Doc+DocName
* Sale=SaleId+Sale
* CustomerService=CustomerService+CustomerServiceName / ForeignCustomerService+ForeignCustomerServiceName
*/
if (item.allotSet.IsAllotCustomerService)
{
if (order.CustomerService != 0 && !string.IsNullOrEmpty(order.CustomerServiceName))
{
item.allotUserList.Add(new RecvUserInfo(order.CustomerService, order.CustomerServiceName));
}
if (order.ForeignCustomerService != 0 && !string.IsNullOrEmpty(order.ForeignCustomerServiceName))
{
item.allotUserList.Add(new RecvUserInfo(order.ForeignCustomerService, order.ForeignCustomerServiceName));
}
}
if (item.allotSet.IsAllotOperator
&& order.OperatorId != 0 && !string.IsNullOrEmpty(order.OperatorName))
{
item.allotUserList.Add(new RecvUserInfo(order.OperatorId, order.OperatorName));
}
if (item.allotSet.IsAllotSale
&& order.SaleId != 0 && !string.IsNullOrEmpty(order.Sale))
{
item.allotUserList.Add(new RecvUserInfo(order.SaleId, order.Sale));
}
if (item.allotSet.IsAllotVouchingClerk
&& order.Doc != 0 && !string.IsNullOrEmpty(order.DocName))
{
item.allotUserList.Add(new RecvUserInfo(order.Doc, order.DocName));
}
}
// 拓展:如果某条任务配置的接收目标为...中的一项,则需要查...
}
allotData = allotData.Where(x => x.allotUserList.Any()).ToList();
foreach (var item in allotData)
{
await SetTaskOwner([item.task.Id], item.allotUserList);
}
var userId = long.Parse(user.UserId);
var currentUserRelateTask = allotData.Where(x => x.allotUserList.Any(y => y.RecvUserId == userId))
.Select(x => x.task).ToList();
result.LoginUserMatchTaskIdList = currentUserRelateTask.Select(x => x.Id).ToList();
result.LoginUserMatchTaskList = currentUserRelateTask.GroupBy(x => new { x.TASK_TYPE, x.TASK_TYPE_NAME })
.Select(x => new MatchTaskClassifyDto()
{
TaskType = x.Key.TASK_TYPE,
TaskTypeName = x.Key.TASK_TYPE_NAME!,
Count = x.Count()
}).ToList();
return DataResult<MatchTaskResultDto>.Success(result, MultiLanguageConst.DataUpdateSuccess);
}
} }
} }

@ -22,7 +22,11 @@ namespace DS.WMS.Core.TaskPlat.Method
public class TaskManageService : TaskManageBaseService<TaskManageService>, ITaskManageService public class TaskManageService : TaskManageBaseService<TaskManageService>, ITaskManageService
{ {
// 实例化时构建
private readonly ICodeCtnService codeCtnService; private readonly ICodeCtnService codeCtnService;
// 按需构建
public TaskManageService(IUser user, public TaskManageService(IUser user,
ILogger<TaskManageService> logger, ILogger<TaskManageService> logger,
ISaasDbService saasDbService, ISaasDbService saasDbService,
@ -31,6 +35,7 @@ namespace DS.WMS.Core.TaskPlat.Method
ICodeCtnService codeCtnService) : base(user, logger, saasDbService, serviceProvider, environment) ICodeCtnService codeCtnService) : base(user, logger, saasDbService, serviceProvider, environment)
{ {
this.codeCtnService = codeCtnService; this.codeCtnService = codeCtnService;
} }
#region 对工作流提供的接口 #region 对工作流提供的接口
@ -1838,6 +1843,5 @@ namespace DS.WMS.Core.TaskPlat.Method
&& a.Status == status) && a.Status == status)
.OrderByDescending(t => t.Id); .OrderByDescending(t => t.Id);
} }
} }
} }

@ -455,4 +455,17 @@ public class SeaExportController : ApiController
{ {
return await _invokeService.RefreshYGT(req.Ids); return await _invokeService.RefreshYGT(req.Ids);
} }
/// <summary>
/// 打印保函
/// </summary>
/// <param name="id">业务Id</param>
/// <returns></returns>
[HttpGet]
[Route("PrintShippingOrderLetterPDF")]
public async Task<DataResult> PrintShippingOrderLetterPDF([FromQuery] string id)
{
var res = await _invokeService.PrintShippingOrderLetterPDF(id);
return res;
}
} }
Loading…
Cancel
Save