cjy 4 weeks ago
commit 36cb21d24f

@ -1554,6 +1554,12 @@ public static class MultiLanguageConst
public const string TaskMailSenderNotNull = "Task_Mail_Sender_Not_Null";
[Description("驳回成功")]
public const string TaskRejected = "Task_Rejected";
[Description("未传入子任务信息")]
public const string SubTaskCannotNull = "Sub_Task_Cannot_Null";
[Description("同一任务的步骤类型不可重复")]
public const string DuplicateStepType = "Duplicate_Step_Type";
[Description("此任务尚有未完成的子任务或前置条件")]
public const string UnfinishedItems = "Unfinished_Items";
#endregion
#region 任务台相关

@ -3,11 +3,57 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Net.NetworkInformation;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace DS.Module.Core.Enums
{
public class EnumsHelper {
///// <summary>
///// 根据枚举值获取枚举Description
///// </summary>
///// <typeparam name="T"></typeparam>
///// <param name="val"></param>
///// <returns></returns>
//public static string GetEnumDescriptionFromValue<T>(T val)
//{
// Type t = typeof(T);
// MemberInfo[] field = t.GetMember(val.ToString());
// object[] attrs = field?.FirstOrDefault().GetCustomAttributes(typeof(DescriptionAttribute), true);
// string description = ((DescriptionAttribute)attrs.FirstOrDefault()).Description;
// return description;
//}
/// <summary>
/// 根据Description获取枚举
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="val"></param>
/// <returns></returns>
///
///// 调用示例
///GetEnumByDescription<enumStudent>("description")
public T GetEnumByDescription<T>(string description) where T : Enum
{
System.Reflection.FieldInfo[] fields = typeof(T).GetFields();
foreach (System.Reflection.FieldInfo field in fields)
{
object[] objs = field.GetCustomAttributes(typeof(DescriptionAttribute), false); //获取描述属性
if (objs.Length > 0 && (objs[0] as DescriptionAttribute).Description == description)
{
return (T)field.GetValue(null);
}
}
throw new ArgumentException(string.Format("{0} 未能找到对应的枚举.", description), "Description");
}
}
/// <summary>
/// 箱管 箱上线状态
/// </summary>
@ -458,4 +504,8 @@ namespace DS.Module.Core.Enums
[Description("审核通过")]
= 1100,
}
}

@ -194,6 +194,7 @@ namespace DS.WMS.ContainerManagement.Info.Method
CtnValue_Base = b.CtnValue_Base,
CreateTime= c.CreateTime,
ProductionDate= b.ProductionDate,
CtnFlowStateId = c.CtnFlowStateId,
});
return query1;

@ -48,6 +48,7 @@ using DS.WMS.Core.Code.Entity;
using NPOI.OpenXmlFormats;
using System.Runtime.CompilerServices;
using iText.StyledXmlParser.Jsoup.Safety;
using Dm;
namespace DS.WMS.ContainerManagement.Info.Method;
@ -1121,7 +1122,45 @@ public class CM_State_Change_TemplatImportService : CMServiceBase, ICM_State_Cha
if (field != null && dt.Columns.Contains(.ColumnTitle))
{
var _value = row[.ColumnTitle];
field.SetValue(newchange, _value);
//field.SetValue(newchange, _value);
if (field.PropertyType.IsGenericType)
{
//if (field.PropertyType.GetGenericTypeDefinition() == typeof(Nullable<>))
//{
if (field.PropertyType.GetGenericArguments()[0] == typeof(DateTime) || field.PropertyType.GetGenericArguments()[0] == typeof(DateTime?))
{
if (_value != null)
{
try {
var _dt = Convert.ToDateTime(_value);
field.SetValue(newchange, _dt);
}
catch (Exception e)
{
var _dt2=DateTime.FromOADate(Convert.ToDouble(_value));
field.SetValue(newchange, _dt2);
}
}
}
else
if (field.PropertyType.GetGenericArguments()[0] == typeof(decimal) || field.PropertyType.GetGenericArguments()[0] == typeof(decimal?))
{
if (_value != null)
{
field.SetValue(newchange, Convert.ToDecimal(_value));
}
}
else
{
field.SetValue(newchange, _value);
}
//}
}
else
{
field.SetValue(newchange, _value);
}
}
else
if (field == null && .FieldTitle == "XXDM")
@ -1133,6 +1172,22 @@ public class CM_State_Change_TemplatImportService : CMServiceBase, ICM_State_Cha
{
XXCM = row[.ColumnTitle].ToString();
}
else
if (field == null && .FieldTitle == "CtnFlowState")
{
//XXCM = row[字段.ColumnTitle].ToString();
//根据字典表对应一个值
field = type.GetProperty("CtnFlowStateId");
if (field != null) {
var tablevalue=row[.ColumnTitle].ToString();
var eh = new EnumsHelper();
var _value=eh.GetEnumByDescription<CMCtnFlowStateEnum>(tablevalue);
field.SetValue(newchange, _value);
}
}
//else
//if (field == null && 字段.FieldTitle == "Vessel")

@ -101,7 +101,9 @@ namespace DS.WMS.Core.Fee.Dtos.Report
/// <summary>
/// 开船日期
/// </summary>
public DateTime? ETD { get; set; }
public string? ETD => ETDValue.HasValue ? ETDValue.Value.ToString("yyyy-MM-dd") : string.Empty;
public DateTime? ETDValue { get; set; }
///// <summary>
///// 预抵日期
@ -219,14 +221,14 @@ namespace DS.WMS.Core.Fee.Dtos.Report
public string StlName { get; set; }
/// <summary>
/// 件数
/// 包装
/// </summary>
public int? PKGS { get; set; }
public string? KindPkgsName { get; set; }
/// <summary>
/// 包装
/// 件数
/// </summary>
public string? KindPkgs { get; set; }
public int? PKGS { get; set; }
/// <summary>
/// 毛重
@ -293,6 +295,29 @@ namespace DS.WMS.Core.Fee.Dtos.Report
/// </summary>
public int ECCU { get; set; }
/// <summary>
/// 船公司
/// </summary>
public string? Carrier { get; set; }
/// <summary>
/// 船名
/// </summary>
public string? Vessel { get; set; }
/// <summary>
/// 航次
/// </summary>
public string? Voyno { get; set; }
/// <summary>
/// 内部航次
/// </summary>
public string? InnerVoyno { get; set; }
/// <summary>
/// 费用统计
/// </summary>
public FeeAuditStatistics Statistics { get; set; }
}

@ -7,6 +7,7 @@ using DS.WMS.Core.Info.Entity;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.TaskInteraction.Dtos;
using Masuit.Tools.Systems;
using SqlSugar;
namespace DS.WMS.Core.Fee.Method.ReportProviders
{
@ -28,6 +29,7 @@ namespace DS.WMS.Core.Fee.Method.ReportProviders
.Select((s, c) => new ProfitAccounting
{
CustomerCode = c.CodeName,
ETDValue = s.ETD,
Sale = s.Sale,
Operator = s.OperatorName,
CustomerService = s.CustomerServiceName,

@ -941,7 +941,7 @@ namespace DS.WMS.Core.Op.EDI
Shipping = formatEdiStr("txt", bill.SHIPPER);
ShippingList = formatlengthStr(Shipping, 35);
ShippingList = formatlengthStr(Shipping, 75);
if (ShippingList.Count != 0 && Shipping.Length > 0)
{
@ -954,31 +954,31 @@ namespace DS.WMS.Core.Op.EDI
Shipping = formatEdiStr("txt", bill.CONSIGNEE);
ShippingList = formatlengthStr(Shipping, 35);
ShippingList = formatlengthStr(Shipping, 75);
if (ShippingList.Count != 0 && Shipping.Length > 0)
{
//2024-09-13 韩工确认最大行数6改为9
r.WriteLine("21::" + formatListStr(ShippingList, 9) + "'");
r.WriteLine("21::" + formatListStr(ShippingList, 6) + "'");
icount = icount + 1;
}
Shipping = formatEdiStr("txt", bill.NOTIFYPARTY);
ShippingList = formatlengthStr(Shipping, 35);
ShippingList = formatlengthStr(Shipping, 75);
if (ShippingList.Count != 0 && Shipping.Length > 0)
{
//2024-09-13 韩工确认最大行数6改为9
r.WriteLine("22::" + formatListStr(ShippingList, 9) + "'");
r.WriteLine("22::" + formatListStr(ShippingList, 6) + "'");
icount = icount + 1;
}
Shipping = formatEdiStr("txt", !string.IsNullOrWhiteSpace(bill.NOTIFYPARTY2) ? bill.NOTIFYPARTY2 : "");
ShippingList = formatlengthStr(Shipping, 35);
ShippingList = formatlengthStr(Shipping, 75);
if (!string.IsNullOrWhiteSpace(Shipping))
{
@ -991,7 +991,7 @@ namespace DS.WMS.Core.Op.EDI
}
Shipping = bill.AMSCONSIGNEE;
ShippingList = formatlengthStr(Shipping, 35);
ShippingList = formatlengthStr(Shipping, 75);
if (!string.IsNullOrWhiteSpace(Shipping))
{
@ -1002,7 +1002,7 @@ namespace DS.WMS.Core.Op.EDI
Shipping = bill.AMSNOTIFYPARTY;
ShippingList = formatlengthStr(Shipping, 35);
ShippingList = formatlengthStr(Shipping, 75);
if (!string.IsNullOrWhiteSpace(Shipping))
{

@ -1,4 +1,5 @@
using DS.Module.Core;
using DS.WMS.Core.TaskInteraction.Entity;
namespace DS.WMS.Core.TaskInteraction.Dtos
{

@ -39,11 +39,31 @@ namespace DS.WMS.Core.TaskInteraction.Dtos
/// </summary>
public string TaskTypeName { get; set; } = string.Empty;
/// <summary>
/// 父级ID用于子任务
/// </summary>
public long? ParentId { get; set; }
/// <summary>
/// 父级业务ID用于子任务
/// </summary>
public long? ParentBusinessId { get; set; }
/// <summary>
/// 附加数据(内部使用)
/// </summary>
public object? ExtraData { get; set; }
/// <summary>
/// 是否自动同步更新主任务状态
/// </summary>
public bool AutoSync { get; set; }
/// <summary>
/// 任务步骤
/// </summary>
public List<TaskStepDto>? Steps { get; set; }
/// <summary>
/// 确定当前对象是否有效
/// </summary>

@ -0,0 +1,35 @@
using DS.WMS.Core.TaskInteraction.Entity;
using SqlSugar;
namespace DS.WMS.Core.TaskInteraction.Dtos
{
/// <summary>
/// 任务步骤
/// </summary>
public class TaskStepDto
{
/// <summary>
/// 步骤类型
/// </summary>
[SugarColumn(ColumnDescription = "明细类型")]
public StepType Type { get; set; }
/// <summary>
/// 名称
/// </summary>
[SugarColumn(ColumnDescription = "名称", Length = 50, IsNullable = true)]
public string? Name { get; set; }
/// <summary>
/// 值
/// </summary>
[SugarColumn(ColumnDescription = "值", IsNullable = true)]
public object? Value { get; set; }
/// <summary>
/// 是否已完成
/// </summary>
[SugarColumn(ColumnDescription = "是否已完成")]
public bool IsCompleted { get; set; }
}
}

@ -20,7 +20,7 @@ namespace DS.WMS.Core.TaskInteraction.Entity
/// <summary>
/// 上级任务ID
/// </summary>
[SugarColumn(ColumnDescription = "上级任务ID")]
[SugarColumn(ColumnDescription = "上级任务ID", IsNullable = true)]
public long? ParentId { get; set; }
/// <summary>
@ -35,6 +35,12 @@ namespace DS.WMS.Core.TaskInteraction.Entity
[SugarColumn(ColumnDescription = "业务类型", IsNullable = false)]
public BusinessType? BusinessType { get; set; }
/// <summary>
/// 上级业务ID
/// </summary>
[SugarColumn(ColumnDescription = "上级业务ID", IsNullable = true)]
public long? ParentBusinessId { get; set; }
/// <summary>
/// 任务类型
/// </summary>
@ -101,5 +107,11 @@ namespace DS.WMS.Core.TaskInteraction.Entity
/// </summary>
[SugarColumn(ColumnDescription = "审批驳回理由", Length = 200, IsNullable = true)]
public string? RejectReason { get; set; }
/// <summary>
/// 任务步骤
/// </summary>
[Navigate(NavigateType.OneToMany, nameof(TaskStep.TaskId))]
public List<TaskStep>? Steps { get; set; }
}
}

@ -0,0 +1,147 @@
using System.ComponentModel;
using Newtonsoft.Json;
using SqlSugar;
namespace DS.WMS.Core.TaskInteraction.Entity
{
/// <summary>
/// 任务步骤表
/// </summary>
[SugarTable("business_task_step", "任务步骤表")]
public class TaskStep
{
/// <summary>
/// ID
/// </summary>
[SugarColumn(IsPrimaryKey = true)]
public long Id { get; set; }
/// <summary>
/// 任务ID
/// </summary>
[SugarColumn(ColumnDescription = "任务ID")]
public long TaskId { get; set; }
/// <summary>
/// 步骤类型
/// </summary>
[SugarColumn(ColumnDescription = "明细类型")]
public StepType Type { get; set; }
/// <summary>
/// 名称
/// </summary>
[SugarColumn(ColumnDescription = "名称", Length = 50, IsNullable = true)]
public string? Name { get; set; }
/// <summary>
/// 值
/// </summary>
[SugarColumn(ColumnDescription = "值", IsNullable = true)]
public string? Value { get; set; }
/// <summary>
/// 是否已完成
/// </summary>
[SugarColumn(ColumnDescription = "是否已完成")]
public bool IsCompleted { get; set; }
/// <summary>
/// 排序值
/// </summary>
[SugarColumn(ColumnDescription = "排序值")]
public int SortOrder { get; set; }
/// <summary>
/// 创建人
/// </summary>
[SugarColumn(ColumnDescription = "创建人", IsNullable = false)]
public long CreateBy { get; set; }
/// <summary>
/// 创建时间
/// </summary>
[SugarColumn(ColumnDescription = "创建时间", IsNullable = false)]
public DateTime CreateTime { get; set; }
/// <summary>
/// 更新人
/// </summary>
[SugarColumn(ColumnDescription = "更新人", IsNullable = true)]
public long? UpdateBy { get; set; }
/// <summary>
/// 更新时间
/// </summary>
[SugarColumn(ColumnDescription = "更新时间", IsNullable = true)]
public DateTime? UpdateTime { get; set; }
/// <summary>
/// 返回指定类型的值
/// </summary>
/// <typeparam name="T">值的类型</typeparam>
/// <returns></returns>
public T? GetValue<T>()
{
if (string.IsNullOrEmpty(Value))
return default;
var type = typeof(T);
if (type.IsEnum)
return (T)Enum.Parse(type, Value);
if (!type.IsClass)
return (T)Convert.ChangeType(Value, type);
return JsonConvert.DeserializeObject<T>(Value);
}
/// <summary>
/// 设置值
/// </summary>
/// <param name="value">要设置的值</param>
/// <returns></returns>
public void SetValue(object? value)
{
if (value == null)
return;
var type = value.GetType();
if (type.IsClass && type != typeof(string))
{
Value = JsonConvert.SerializeObject(value);
}
else
{
Value = value.ToString();
}
}
}
/// <summary>
/// 任务步骤类型
/// </summary>
public enum StepType
{
/// <summary>
/// 未指定
/// </summary>
[Description("未指定")]
NotSpecified = 0,
/// <summary>
/// 客户确认
/// </summary>
[Description("客户确认")]
CustomerConfirm = 1,
/// <summary>
/// 国外代理确认
/// </summary>
[Description("国外代理确认")]
ForeignAgentConfirm = 2,
}
}

@ -58,6 +58,14 @@ namespace DS.WMS.Core.TaskInteraction.Interface
/// <returns></returns>
Task<DataResult> SetTaskStatusAsync(TaskUpdateRequest request, bool useTransaction = true);
/// <summary>
/// 设置任务步骤状态
/// </summary>
/// <param name="request"></param>
/// <param name="useTransaction">是否使用事务</param>
/// <returns></returns>
Task<DataResult> SetStepsAsync(TaskRequest request, bool useTransaction = true);
/// <summary>
/// 更新任务台描述
/// </summary>

@ -1,16 +1,19 @@
using DS.WMS.Core.TaskInteraction.Dtos;
using DS.Module.Core;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.TaskInteraction.Dtos;
using DS.WMS.Core.TaskInteraction.Entity;
using DS.WMS.Core.TaskInteraction.Interface;
using DS.WMS.Core.TaskPlat.Interface;
using Masuit.Tools.Systems;
using Microsoft.Extensions.DependencyInjection;
namespace DS.WMS.Core.TaskInteraction.Method.ActionExecutor.BLConfirm
{
/// <summary>
/// 分单提单确认
/// 分单提单确认动作
/// </summary>
public class SubBLConfirmActionExecutor : ServiceBase, IActionExecutor
{
ITaskManageBCService bCService;
//ITaskManageBCService bCService;
ISeaExportTaskService taskService;
ITaskLogService logService;
@ -20,7 +23,7 @@ namespace DS.WMS.Core.TaskInteraction.Method.ActionExecutor.BLConfirm
/// <param name="provider"></param>
public SubBLConfirmActionExecutor(IServiceProvider provider) : base(provider)
{
bCService = provider.GetRequiredService<ITaskManageBCService>();
//bCService = provider.GetRequiredService<ITaskManageBCService>();
taskService = provider.GetRequiredService<ISeaExportTaskService>();
logService = provider.GetRequiredService<ITaskLogService>();
}
@ -32,8 +35,77 @@ namespace DS.WMS.Core.TaskInteraction.Method.ActionExecutor.BLConfirm
/// <returns></returns>
public async Task ExecuteAsync(ActionExecutionContext context)
{
//if (await taskService)
//{
//}
var bills = await TenantDb.Queryable<SeaExportBillManage>().Where(x => x.BusinessId == context.TaskInfo.BusinessId)
.Select(x => new
{
x.Id,
x.HBLNO,
x.BillType,
x.Vessel,
x.Voyno,
x.ETD,
}).ToListAsync();
if (bills.Count == 0)
return;
DataResult result;
long userId = long.Parse(User.UserId);
var dtNow = DateTime.Now;
await TenantDb.Ado.BeginTranAsync();
try
{
foreach (var bill in bills)
{
var req = new TaskCreationRequest
{
ParentId = context.TaskInfo.Id,
ParentBusinessId = context.TaskInfo.BusinessId,
BusinessId = bill.Id,
BusinessType = context.TaskInfo.BusinessType,
TaskTypeName = TaskBaseTypeEnum.WAIT_SUB_BILL_CONFIRM.ToString(),
TaskTitle = $"{bill.BillType} {bill.HBLNO} {bill.ETD} {bill.Vessel}|{bill.Voyno}",
Steps = []
};
req.Steps.Add(new TaskStepDto
{
Type = StepType.CustomerConfirm,
Name = StepType.CustomerConfirm.ToString()
});
req.Steps.Add(new TaskStepDto
{
Type = StepType.ForeignAgentConfirm,
Name = StepType.ForeignAgentConfirm.ToString()
});
result = await taskService.CreateTaskAsync(req, false);
if (!result.Succeeded)
{
await logService.WriteLogAsync(new BusinessTask
{
BusinessId = req.BusinessId,
BusinessType = req.BusinessType,
TaskStatus = TaskStatusEnum.Create,
TaskType = req.TaskType,
CreateBy = userId,
CreateTime = dtNow
}, $"创建【{req.TaskType.GetDescription()}】任务时出错:" + result.Message);
return;
}
}
await TenantDb.Ado.CommitTranAsync();
}
catch (Exception ex)
{
await TenantDb.Ado.RollbackTranAsync();
await ex.LogAsync(Db);
}
}
}

@ -433,7 +433,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
SendTo = sendTo,
Title = title,
Body = content,
CCTo = string.Join(",", ccList),
CCTo = string.Join(";", ccList),
ShowName = senderConfig.ShowName.IsNullOrEmpty() ? templateModel.Sender.DisplayName : senderConfig.ShowName,
Account = senderConfig.MailAccount,
senderConfig.Password,

@ -1,5 +1,4 @@
using System.Text;
using System.Threading.Tasks;
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.Module.Core.Helpers;
@ -245,6 +244,9 @@ namespace DS.WMS.Core.TaskInteraction.Method
return result;
}
long userId = long.Parse(User.UserId);
DateTime dtNow = DateTime.Now;
if (useTransaction)
await TenantDb.Ado.BeginTranAsync();
try
@ -355,20 +357,40 @@ namespace DS.WMS.Core.TaskInteraction.Method
task = new BusinessTask
{
ParentId = request.ParentId,
BusinessId = request.BusinessId,
BusinessType = request.BusinessType,
ParentBusinessId = request.ParentBusinessId,
TaskType = request.TaskType,
TaskStatus = TaskStatusEnum.Create,
RecvUsers = string.Join(',', info.Main.RecvUserInfoList.Select(x => x.RecvUserId)) ?? string.Empty,
NextType = request.NextType,
CreateBy = long.Parse(User.UserId),
CreateTime = DateTime.Now
CreateBy = userId,
CreateTime = dtNow
};
if (IsOrderType(request.TaskType) && !task.NextType.HasValue)
task.NextType = await GetNextTypeAsync(task);
await TenantDb.Insertable(task).ExecuteCommandAsync();
if (request.Steps?.Count > 0)
{
if (request.Steps.Where(x => x.Type != StepType.NotSpecified).GroupBy(x => x.Type).Select(x => x.Key).Count() > 1)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.DuplicateStepType));
var steps = request.Steps.Select(x => new TaskStep
{
TaskId = task.Id,
IsCompleted = x.IsCompleted,
Name = x.Name,
Type = x.Type,
SortOrder = request.Steps.IndexOf(x),
CreateBy = userId,
CreateTime = dtNow
}).ToList();
await TenantDb.Insertable(request.Steps).ExecuteCommandAsync();
}
result = await OnTaskCreated(task);
if (!result.Succeeded)
@ -542,8 +564,14 @@ namespace DS.WMS.Core.TaskInteraction.Method
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskNotExists));
if (task.TaskStatus == TaskStatusEnum.Complete)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskCompleted));
//if (task.TaskStatus == TaskStatusEnum.Cancel)
// return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskCancelled));
//检查是否有未完成的任务步骤
var steps = await TenantDb.Queryable<TaskStep>().Where(x => x.TaskId == task.Id && !x.IsCompleted)
.Select(x => new { x.Type, x.Name }).ToListAsync();
if (steps.Count > 0)
return DataResult.Failed(
MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.UnfinishedItems)) + "" + string.Join("|", steps.Select(x => x.Type == StepType.NotSpecified ? x.Name : x.Type.GetDescription())),
nameof(MultiLanguageConst.UnfinishedItems));
//触发任务状态变更通知
if (task.TaskStatus != request.TaskStatus)
@ -616,6 +644,102 @@ namespace DS.WMS.Core.TaskInteraction.Method
}
}
/// <summary>
/// 设置任务步骤状态
/// </summary>
/// <param name="request"></param>
/// <param name="useTransaction">是否使用事务</param>
/// <returns></returns>
public async Task<DataResult> SetStepsAsync(TaskRequest request, bool useTransaction = true)
{
if (!await HasAuthorizedAsync())
return DataResult.FailedWithDesc(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.ModuleUnauthorized)));
if (request.Steps == null || request.Steps.Count == 0)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.SubTaskCannotNull));
if (useTransaction)
await TenantDb.Ado.BeginTranAsync();
try
{
BusinessTask task = await GetQuery(request.BusinessId, request.BusinessType, request.TaskType).FirstAsync();
if (task == null)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskNotExists));
if (task.TaskStatus == TaskStatusEnum.Complete)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskCompleted));
var stepTypes = request.Steps.Select(x => x.Type);
var steps = await TenantDb.Queryable<TaskStep>().Where(x => x.TaskId == task.Id && stepTypes.Contains(x.Type))
.Select(x => new TaskStep
{
Id = x.Id,
Type = x.Type,
Name = x.Name,
SortOrder = x.SortOrder
}).ToListAsync();
long userId = long.Parse(User.UserId);
DateTime dtNow = DateTime.Now;
foreach (var item in steps)
{
var reqStep = request.Steps.Find(x => x.Type == item.Type);
if (reqStep == null)
continue;
item.SetValue(reqStep.Value);
item.IsCompleted = reqStep.IsCompleted;
item.UpdateBy = userId;
item.UpdateTime = dtNow;
}
await TenantDb.Updateable(steps).UpdateColumns(x => new
{
x.Value,
x.IsCompleted,
x.UpdateBy,
x.UpdateTime
}).ExecuteCommandAsync();
if (request.AutoSync)
{
var allSteps = await TenantDb.Queryable<TaskStep>().Where(x => x.TaskId == task.Id)
.Select(x => new
{
x.Id,
x.IsCompleted
}).ToListAsync();
if (allSteps.Count > 0 && allSteps.Count == allSteps.Count(x => x.IsCompleted))
{
var result = await SetTaskStatusAsync(new TaskUpdateRequest
{
BusinessId = task.BusinessId,
BusinessType = task.BusinessType,
TaskTypeName = request.TaskTypeName,
TaskStatus = TaskStatusEnum.Complete
}, false);
if (!result.Succeeded)
return result;
}
}
if (useTransaction)
await TenantDb.Ado.CommitTranAsync();
return DataResult.Success;
}
catch (Exception ex)
{
if (useTransaction)
await TenantDb.Ado.RollbackTranAsync();
await ex.LogAsync(Db);
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
}
}
/// <summary>
/// 当任务状态发生变化时调用
/// </summary>

@ -1,35 +1,283 @@
using System;
using LanguageExt;
using Masuit.Tools.Strings;
using Microsoft.AspNetCore.Identity;
using NPOI.HPSF;
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static iText.StyledXmlParser.Jsoup.Select.Evaluator;
namespace DS.WMS.Core.Utils
{
public class ExportFileHelper
{
/// <summary>
/// 导出
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="list"></param>
/// <param name="colDicts"></param>
/// <returns></returns>
public async Task<string> Export<T>(List<T> dataLiist, Dictionary<string,string> colDicts)
{
string filePath = string.Empty;
// /// <summary>
// /// 导出
// /// </summary>
// /// <typeparam name="T"></typeparam>
// /// <param name="list"></param>
// /// <param name="colDicts"></param>
// /// <returns></returns>
// public async Task<string> Export<T>(List<T> dataLiist, Dictionary<string,string> colDicts)
// {
// string filePath = string.Empty;
try
{
// /*
// 1、生成空Excel文件。
// 2、根据colDicts提供的key来匹配字段列表的
// 3、暂存文件并返回完整文件名
// */
// try
// {
// string sheetName = "";
// XSSFWorkbook workbook = new XSSFWorkbook();
// ISheet sheet = workbook.CreateSheet(sheetName);
}
catch(Exception ex)
{
// #region Excel模板打印
// //var opt = App.GetOptions<PrintTemplateOptions>();
// //var dirAbs = opt.basePath;
// //if (string.IsNullOrEmpty(dirAbs))
// //{
// // dirAbs = App.WebHostEnvironment.WebRootPath;
// //}
// var fileAbsPath = Path.Combine(dirAbs, printTemplate.FilePath);
// //_logger.LogInformation($"准备调用EXCEL生成id{id},文件:{printTemplate.FileName}");
}
return filePath;
}
// var result = new FileStream(fileAbsPath, FileMode.Open);
// var excelwork = new HSSFWorkbook(result);
// var sheet = excelwork.GetSheetAt(0);
// var entity = await _bookingExcelTemplateRepository.AsQueryable()
// .Where(x => x.PId == templateId).OrderBy(x => x.Row).ToListAsync();
// if (entity == null)
// {
// throw Oops.Bah("当前模板未设置");
// }
// for (int _row = 1; _row <= entity.Max(x => x.Row); _row++)
// {
// if (entity.Where(x => x.Row == _row).Count() > 0)
// {
// ////获取行
// var row = sheet.GetRow(_row - 1);
// if (row != null)
// {
// for (int _cellNum = 1; _cellNum <= entity.Max(x => x.Column); _cellNum++)
// {
// if (entity.Where(x => x.Row == _row && x.Column == _cellNum).Count() > 0)
// {
// var name = entity.Where(x => x.Row == _row && x.Column == _cellNum).Select(x => x.Field).FirstOrDefault();
// if (name.Split('.')[0].ToLower() == "order")
// {
// foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(order))
// {
// var _name = descriptor.Name.ToLower();
// if (name.Split('.')[0].ToLower() == "order" && name.Split('.')[1].ToLower() == _name)
// {
// var value = descriptor.GetValue(order) != null ? descriptor.GetValue(order).ToString() : "";
// ICell cell = row.GetCell(_cellNum - 1);
// if (descriptor.PropertyType.FullName.Contains("DateTime"))
// {
// value = value != "" ? Convert.ToDateTime(value).ToString("yyyy-MM-dd") : "";
// }
// if (cell != null)
// {
// row.Cells[_cellNum - 1].SetCellValue(value);
// }
// else
// {
// row.CreateCell(_cellNum - 1).SetCellValue(value);
// }
// }
// }
// }
// if (name.Split('.')[0].ToLower() == "edi")
// {
// foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(edi))
// {
// var _name = descriptor.Name.ToLower();
// if (name.Split('.')[0].ToLower() == "edi" && name.Split('.')[1].ToLower() == _name)
// {
// var value = descriptor.GetValue(edi) != null ? descriptor.GetValue(edi).ToString() : "";
// ICell cell = row.GetCell(_cellNum - 1);
// if (descriptor.PropertyType.FullName.Contains("DateTime"))
// {
// value = value != "" ? Convert.ToDateTime(value).ToString("yyyy-MM-dd") : "";
// }
// if (cell != null)
// {
// row.Cells[_cellNum - 1].SetCellValue(value);
// }
// else
// {
// row.CreateCell(_cellNum - 1).SetCellValue(value);
// }
// }
// }
// }
// if (name.Split('.')[0].ToLower() == "userinfo")
// {
// ICell cell = row.GetCell(_cellNum - 1);
// var value = string.Empty;
// if (name.Split('.')[1].ToLower() == "username")
// {
// value = UserManager.Name;
// }
// if (name.Split('.')[1].ToLower() == "usertel")
// {
// value = UserManager.TEl;
// }
// if (name.Split('.')[1].ToLower() == "usermobile")
// {
// value = UserManager.Phone;
// }
// if (name.Split('.')[1].ToLower() == "useremail")
// {
// value = UserManager.Email;
// }
// if (name.Split('.')[1].ToLower() == "usertenant")
// {
// value = UserManager.TENANT_NAME;
// }
// if (cell != null)
// {
// row.Cells[_cellNum - 1].SetCellValue(value);
// }
// else
// {
// row.CreateCell(_cellNum - 1).SetCellValue(value);
// }
// }
// }
// }
// }
// else
// {
// ////创建行
// var srow = NpoiExcelExportHelper._.CreateRow(sheet, _row - 1);
// for (int _cellNum = 1; _cellNum <= entity.Max(x => x.Column); _cellNum++)
// {
// if (entity.Where(x => x.Row == _row && x.Column == _cellNum).Count() > 0)
// {
// var name = entity.Where(x => x.Row == _row && x.Column == _cellNum).Select(x => x.Field).FirstOrDefault();
// if (name.Split('.')[0].ToLower() == "order")
// {
// foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(order))
// {
// var _name = descriptor.Name.ToLower();
// if (name.Split('.')[1].ToLower() == _name && name.Split('.')[0].ToLower() == "order")
// {
// var value = descriptor.GetValue(order) != null ? descriptor.GetValue(order).ToString() : "";
// if (descriptor.PropertyType.FullName.Contains("DateTime"))
// {
// value = value != "" ? Convert.ToDateTime(value).ToString("yyyy-MM-dd") : "";
// }
// srow.CreateCell(_cellNum - 1).SetCellValue(value);
// }
// }
// }
// if (name.Split('.')[0].ToLower() == "edi")
// {
// foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(edi))
// {
// var _name = descriptor.Name.ToLower();
// if (name.Split('.')[1].ToLower() == _name && name.Split('.')[0].ToLower() == "edi")
// {
// var value = descriptor.GetValue(edi) != null ? descriptor.GetValue(edi).ToString() : "";
// if (descriptor.PropertyType.FullName.Contains("DateTime"))
// {
// value = value != "" ? Convert.ToDateTime(value).ToString("yyyy-MM-dd") : "";
// }
// srow.CreateCell(_cellNum - 1).SetCellValue(value);
// }
// }
// }
// if (name.Split('.')[0].ToLower() == "userinfo")
// {
// var value = string.Empty;
// if (name.Split('.')[1].ToLower() == "username")
// {
// value = UserManager.Name;
// }
// if (name.Split('.')[1].ToLower() == "usertel")
// {
// value = UserManager.TEl;
// }
// if (name.Split('.')[1].ToLower() == "usermobile")
// {
// value = UserManager.Phone;
// }
// if (name.Split('.')[1].ToLower() == "useremail")
// {
// value = UserManager.Email;
// }
// if (name.Split('.')[1].ToLower() == "usertenant")
// {
// value = UserManager.TENANT_NAME;
// }
// srow.CreateCell(_cellNum - 1).SetCellValue(value);
// }
// }
// }
// }
// }
// }
// var fileFullPath = Path.Combine(App.WebHostEnvironment.WebRootPath, App.GetOptions<TempFileOptions>().Path);//服务器路径
// if (!Directory.Exists(fileFullPath))
// {
// Directory.CreateDirectory(fileFullPath);
// }
// fileName = $"{DateTime.Now.Ticks}.xls";//名称
// ////2023-4-3根据河川操作要求文件名只带提单号
// //if (!string.IsNullOrEmpty(order.MBLNO))
// //{
// // fileName = $"{order.MBLNO}.xls";//名称
// //}
// //else
// //{
// // fileName = $"{order.Id}_{DateTime.Now.Ticks}.xls";//名称
// //}
// _logger.LogInformation("导出excel:" + Path.Combine(fileFullPath, fileName));
// var filestream = new FileStream(Path.Combine(fileFullPath, fileName), FileMode.OpenOrCreate, FileAccess.ReadWrite);
// excelwork.Write(filestream);
// #endregion
// }
// catch (Exception ex)
// {
// }
// return filePath;
// }
//}
}
}

@ -84,7 +84,12 @@ namespace DS.WMS.OpApi.Controllers
{
var result = await taskService.GetTasks(request.BusinessId, request.BusinessType, request.TaskType);
if (result.Data?.Count > 0)
return await actionService.TriggerActionAsync(result.Data[0].Adapt<BusinessTask>(), false);
{
var task = result.Data[0].Adapt<BusinessTask>();
task.BusinessId = request.BusinessId;
task.BusinessType = request.BusinessType;
return await actionService.TriggerActionAsync(task, false);
}
return DataResult.FailedWithDesc(MultiLanguageConst.EmptyData);
}
@ -159,6 +164,20 @@ namespace DS.WMS.OpApi.Controllers
return await taskService.SetTaskStatusAsync(request);
}
/// <summary>
/// 设置任务步骤
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost, Route("SetSteps")]
public async Task<DataResult> SetStepsAsync(TaskRequest request)
{
if (!ModelState.IsValid)
return DataResult.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest);
return await taskService.SetStepsAsync(request);
}
/// <summary>
/// 手动发起任务审核(用于二次审核)
/// </summary>

@ -120,7 +120,7 @@
"Port": 465,
"UseSSL": true,
"Receivers": "candy@sunniness.net",
"CCTo": "yee@sunniness.net,daisusu@dongshengsoft.com",
"CCTo": "yee@sunniness.net;daisusu@dongshengsoft.com",
"Title": "WSL Volume Daily Increase Report",
"Body": "<article class='4ever-article'><p style='line-height: 1;'>Dear WSL Team,</p><p style='line-height: 1;'>Pls kindly check the daily report for your member's nomination booking:&nbsp;</p><p style='line-height: 1;'>&nbsp;</p><p style='line-height: 1;'>Thanks &amp; Best regards</p><p style='line-height: 1;'>Candy SHAO 邵芳</p><p style='line-height: 1;'>General Manager| <strong><span style='color: #e67e23;'>SUNNINESS LOGISTICS CO.,LTD.</span></strong></p><p style='line-height: 1;'>TEL: +(86) (0532-80688387)1 MB./We chat: +(86)(18866622731) | QQ:2853083553|Email:candy@sunniness. net |WCA ID: 60272</p></article>"
}

Loading…
Cancel
Save