diff --git a/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs b/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs index 75b2b33b..5dc4843e 100644 --- a/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs +++ b/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs @@ -1744,4 +1744,73 @@ public static class MultiLanguageConst [Description("还存在未处理上线状态的导入明细")] public const string CM_NoDealTempDetail = "Exists some Detail need to deal."; #endregion + + #region 服务项目 + /// + /// 状态代码或名称不能为空 + /// + [Description("状态代码或名称不能为空")] + public const string ServiceProjectStatusSkuSaveNameNull = "ServiceProject_StatusSku_SaveNameNull"; + + /// + /// 排序值不能小于等于0 + /// + [Description("排序值不能小于等于0")] + public const string ServiceProjectStatusSkuSaveSortNotEqualLessZero = "ServiceProject_StatusSku_SaveSortNotEqualLessZero"; + + /// + /// 状态信息不能为空 + /// + [Description("状态信息不能为空")] + public const string ServiceProjectStatusSkuSaveModelNull = "ServiceProject_StatusSku_SaveModelNull"; + + /// + /// 状态代码已存在不能重复保存 + /// + [Description("状态代码已存在不能重复保存")] + public const string ServiceProjectStatusSkuSaveCodeExists = "ServiceProject_StatusSku_SaveCodeExists"; + + /// + /// 状态主键不能为空 + /// + [Description("状态主键不能为空")] + public const string ServiceProjectStatusSkuSaveIdNull = "ServiceProject_StatusSku_SaveIdNull"; + + /// + /// 状态获取失败,状态信息不存在或已作废 + /// + [Description("状态获取失败,状态信息不存在或已作废")] + public const string ServiceProjectStatusSkuEntityNull = "ServiceProject_StatusSku_EntityNull"; + + /// + /// 当前状态已关联服务流程活动,不能修改 + /// + [Description("当前状态已关联服务流程活动,不能修改")] + public const string ServiceProjectStatusSkuHasRelateWFAct = "ServiceProject_StatusSku_HasRelateWFAct"; + + /// + /// 状态代码和状态名称不能小于2个字符,不能修改 + /// + [Description("状态代码和状态名称不能小于2个字符,不能修改")] + public const string ServiceProjectStatusSkuCodeNameLessTwoChar = "ServiceProject_StatusSku_HasRelateWFAct"; + + /// + /// 当前状态已关联服务流程活动,不能取消启用 + /// + [Description("当前状态已关联服务流程活动,不能取消启用")] + public const string ServiceProjectStatusSkuHasRelateWFActNotSetUnEnable = "ServiceProject_StatusSku_HasRelateWFActNotSetUnEnable"; + + /// + /// 状态主键数组不能为空 + /// + [Description("状态主键数组不能为空")] + public const string ServiceProjectStatusSkuBatchIdsNull = "ServiceProject_StatusSku_BatchIdsNull"; + + /// + /// 部分状态获取失败,请确认状态是否存在 + /// + [Description("部分状态获取失败,请确认状态是否存在")] + public const string ServiceProjectStatusSkuEntityPartNull = "ServiceProject_StatusSku_EntityPartNull"; + + #endregion } \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/DS.WMS.Core.csproj b/ds-wms-service/DS.WMS.Core/DS.WMS.Core.csproj index d7a50501..76141ffd 100644 --- a/ds-wms-service/DS.WMS.Core/DS.WMS.Core.csproj +++ b/ds-wms-service/DS.WMS.Core/DS.WMS.Core.csproj @@ -43,7 +43,6 @@ - diff --git a/ds-wms-service/DS.WMS.Core/Op/Dtos/Enum/TrackingOperateTypeEnum.cs b/ds-wms-service/DS.WMS.Core/Op/Dtos/Enum/TrackingOperateTypeEnum.cs new file mode 100644 index 00000000..f0ee44bf --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Op/Dtos/Enum/TrackingOperateTypeEnum.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DS.WMS.Core.Op.Dtos +{ + /// + /// 服务项目操作类型枚举 + /// + public enum TrackingOperateTypeEnum + { + /// + /// 保存 + /// + [Description("保存")] + Save, + /// + /// 提交 + /// + [Description("提交")] + Submit, + /// + /// 取消 + /// + [Description("取消")] + Cancel, + /// + /// 删除 + /// + [Description("删除")] + Delete, + /// + /// 派车 + /// + [Description("派车")] + SendDispatch, + /// + /// 取消派车 + /// + [Description("取消派车")] + CancelDispatch, + /// + /// 派车回写详情 + /// + [Description("派车回写详情")] + DispatchBackSave, + /// + /// 设定启用 + /// + [Description("设定启用")] + SetEnable, + /// + /// 设定不启用 + /// + [Description("设定不启用")] + SetUnEnable + } +} diff --git a/ds-wms-service/DS.WMS.Core/Op/Dtos/ServiceProject/StatusSkuBaseQueryExtDto.cs b/ds-wms-service/DS.WMS.Core/Op/Dtos/ServiceProject/StatusSkuBaseQueryExtDto.cs new file mode 100644 index 00000000..fdd35824 --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Op/Dtos/ServiceProject/StatusSkuBaseQueryExtDto.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DS.WMS.Core.Op.Dtos.ServiceProject +{ + /// + /// 服务项目状态台账查询扩展 + /// + public class StatusSkuBaseQueryExtDto + { + /// + /// 创建起始时间 + /// + public Nullable CreateStart { get; set; } + + /// + /// 创建结束时间 + /// + public Nullable CreateEnd { get; set; } + + /// + /// 更新起始时间 + /// + public Nullable UpdateStart { get; set; } + + /// + /// 更新结束时间 + /// + public Nullable UpdateEnd { get; set; } + + /// + /// 是否启用 1-已启用 2-未启用 + /// + /// + public string IsEnable { get; set; } + + /// + /// 状态名称 + /// + public string StatusSKUName { get; set; } + + /// + /// 状态说明 + /// + public string StatusSKUNote { get; set; } + + + /// + /// 创建人 + /// + public Nullable CreateBy { get; set; } + + /// + /// 更新人 + /// + public Nullable UpdateBy { get; set; } + } +} diff --git a/ds-wms-service/DS.WMS.Core/Op/Dtos/ServiceProject/TrackingSystemMapper.cs b/ds-wms-service/DS.WMS.Core/Op/Dtos/ServiceProject/TrackingSystemMapper.cs index a7ba486c..f9bf41cf 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Dtos/ServiceProject/TrackingSystemMapper.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Dtos/ServiceProject/TrackingSystemMapper.cs @@ -15,20 +15,22 @@ namespace DS.WMS.Core.Op.Dtos { public void Register(TypeAdapterConfig config) { - /* + config.ForType() - .Map(dest => dest.PK_ID, src => src.PKId) + .Map(dest => dest.Id, src => src.Id) .Map(dest => dest.SERVICE_PROJECT_CODE, src => src.ServiceProjectCode) .Map(dest => dest.SERVICE_PROJECT_NAME, src => src.ServiceProjectName) .Map(dest => dest.SORT_NO, src => src.SortNo) .Map(dest => dest.SERVICE_PROJECT_NOTE, src => src.ServiceProjectNote); config.ForType() - .Map(dest => dest.PKId, src => src.PK_ID) + .Map(dest => dest.Id, src => src.Id) .Map(dest => dest.ServiceProjectCode, src => src.SERVICE_PROJECT_CODE) .Map(dest => dest.ServiceProjectName, src => src.SERVICE_PROJECT_NAME) .Map(dest => dest.SortNo, src => src.SORT_NO); + + /* config.ForType() .Map(dest => dest.PKId, src => src.PK_ID) .Map(dest => dest.ServiceProjectCode, src => src.SERVICE_PROJECT_CODE) diff --git a/ds-wms-service/DS.WMS.Core/Op/Entity/ServiceProject/StatusSkuBaseInfo.cs b/ds-wms-service/DS.WMS.Core/Op/Entity/ServiceProject/StatusSkuBaseInfo.cs index 92b5808c..e3b25768 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Entity/ServiceProject/StatusSkuBaseInfo.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Entity/ServiceProject/StatusSkuBaseInfo.cs @@ -13,8 +13,14 @@ namespace DS.WMS.Core.Op.Entity /// 状态主表 /// [SqlSugar.SugarTable("status_sku_base", "状态主表")] - public class StatusSkuBaseInfo : BaseModelV2 + public class StatusSkuBaseInfo { + /// + /// 主键 + /// + [SugarColumn(ColumnDescription = "主键", IsPrimaryKey = true)] + public string PK_ID { get; set; } + /// /// 状态代码 /// @@ -44,5 +50,75 @@ namespace DS.WMS.Core.Op.Entity /// 状态说明 /// public string STATUS_SKU_NOTE { get; set; } + + /// + /// 创建时间 + /// + [Description("创建时间")] + [SugarColumn(IsOnlyIgnoreUpdate = true, ColumnDescription = "创建时间")] + public DateTime CreateTime { get; set; } + + /// + /// 创建人 + /// + [Description("创建人")] + [SugarColumn(IsOnlyIgnoreUpdate = true, IsNullable = true, ColumnDescription = "创建人")] + public long CreateBy { get; set; } + + /// + /// 修改人 + /// + [Description("修改人")] + [SugarColumn(IsNullable = true, ColumnDescription = "修改人")] + public long? UpdateBy { get; set; } + + /// + /// 更新时间 + /// + [Description("更新时间")] + [SugarColumn(IsNullable = true, ColumnDescription = "更新时间")] + public Nullable UpdateTime { get; set; } + + /// + /// 删除 + /// + [Description("删除")] + [SugarColumn(ColumnDescription = "是否删除", DefaultValue = "0")] + public bool Deleted { get; set; } + + /// + /// 删除时间 + /// + [Description("删除时间")] + [SugarColumn(IsNullable = true, ColumnDescription = "删除时间", IsOnlyIgnoreInsert = true)] + public Nullable DeleteTime { get; set; } + + /// + /// 删除人 + /// + [Description("删除人")] + [SugarColumn(IsNullable = true, ColumnDescription = "删除人", IsOnlyIgnoreInsert = true)] + public Nullable DeleteBy { get; set; } + + /// + /// 创建人名称 + /// + [Description("创建人名称")] + [SugarColumn(IsOnlyIgnoreUpdate = true, IsNullable = true, ColumnDescription = "创建人名称", Length = 50)] + public string CreateUserName { get; set; } + + /// + /// 修改人名称 + /// + [Description("修改人名称")] + [SugarColumn(IsNullable = true, ColumnDescription = "修改人名称", Length = 50)] + public string UpdateUserName { get; set; } + + /// + /// 删除人名称 + /// + [Description("删除人名称")] + [SugarColumn(IsNullable = true, ColumnDescription = "删除人名称", Length = 50, IsOnlyIgnoreInsert = true)] + public string DeleteUserName { get; set; } } } diff --git a/ds-wms-service/DS.WMS.Core/Op/Interface/ServiceProject/IStatusSkuBaseService.cs b/ds-wms-service/DS.WMS.Core/Op/Interface/ServiceProject/IStatusSkuBaseService.cs index f6f37b1a..a082ab97 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Interface/ServiceProject/IStatusSkuBaseService.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Interface/ServiceProject/IStatusSkuBaseService.cs @@ -18,42 +18,42 @@ namespace Myshipping.Application /// /// 状态详情 /// 返回回执 - Task> Save(StatusSkuBaseDto info); + Task> Save(StatusSkuBaseDto info); /// /// 保存并启用 /// /// 状态详情 /// 返回回执 - Task> SaveAndEnable(StatusSkuBaseDto info); + Task> SaveAndEnable(StatusSkuBaseDto info); /// /// 启用 /// - /// 状态主键数组 + /// 状态主键数组 /// 返回回执 - Task> SetEnable(string[] pkIds); + Task> SetEnable(string[] ids); /// /// 取消启用 /// - /// 状态主键数组 + /// 状态主键数组 /// 返回回执 - Task> SetUnEnable(string[] pkIds); + Task> SetUnEnable(string[] ids); /// /// 删除 /// - /// 状态主键数组 + /// 状态主键数组 /// 返回回执 - Task> Delete(string[] pkIds); + Task> Delete(string[] ids); /// /// 获取状态详情 /// - /// 状态主键 + /// 状态主键 /// 返回回执 - Task> GetInfo(string pkId); + Task> GetInfo(string id); /// /// 检索状态列表 @@ -66,9 +66,9 @@ namespace Myshipping.Application /// /// 状态台账查询 /// - /// 状态台账查询请求 + /// 状态台账查询请求 /// 返回结果 - Task> GetPageAsync(QueryStatusSkuBaseDto QuerySearch); + Task>> GetPageAsync(PageRequest querySearch); } } diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/ServiceProject/StatusSkuBaseService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/ServiceProject/StatusSkuBaseService.cs new file mode 100644 index 00000000..865f6861 --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Op/Method/ServiceProject/StatusSkuBaseService.cs @@ -0,0 +1,730 @@ +using Myshipping.Application; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using NLog; +using DS.Module.UserModule; +using SqlSugar; +using DS.Module.SqlSugar; +using Microsoft.Extensions.DependencyInjection; +using DS.Module.DjyServiceStatus; +using DS.WMS.Core.Op.Dtos; +using DS.WMS.Core.Op.Entity; +using Microsoft.AspNetCore.Identity; +using Microsoft.AspNetCore.Mvc; +using NPOI.SS.Formula.Functions; +using DS.Module.Core; +using System.Text.Json.Serialization; +using Newtonsoft.Json; +using DS.WMS.Core.Invoice.Dtos; +using Mapster; +using LanguageExt.Common; +using DS.WMS.Core.Op.Dtos.ServiceProject; +using DS.Module.Core.Extensions; +using DS.WMS.Core.Op.Dtos.Enum; + +namespace DS.WMS.Core.Op.Method +{ + /// + /// 状态管理 + /// + public class StatusSkuBaseService: IStatusSkuBaseService + { + private readonly IServiceProvider _serviceProvider; + private readonly ISqlSugarClient db; + private readonly IUser user; + private readonly ISaasDbService saasService; + + private static readonly NLog.Logger Logger = LogManager.GetCurrentClassLogger(); + + public StatusSkuBaseService(IServiceProvider serviceProvider) + { + _serviceProvider = serviceProvider; + db = _serviceProvider.GetRequiredService(); + user = _serviceProvider.GetRequiredService(); + saasService = _serviceProvider.GetRequiredService(); + } + + #region 保存 + /// + /// 保存 + /// + /// 状态详情 + /// 返回回执 + public async Task> Save([FromBody] StatusSkuBaseDto info) + { + return await InnerSave(info); + } + #endregion + + #region 保存内部方法 + /// + /// 保存内部方法 + /// + /// 服务项目详情 + /// 是否启用 + /// 返回派车Id + private async Task> InnerSave(StatusSkuBaseDto info, bool isSetEnable = false) + { + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + + StatusSkuBaseInfo entity = info.Adapt(); + + if (isSetEnable) + { + if (string.IsNullOrWhiteSpace(entity.STATUS_SKU_CODE) || string.IsNullOrWhiteSpace(entity.STATUS_SKU_NAME)) + { + //状态代码或名称不能为空 + throw new Exception(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.ServiceProjectStatusSkuSaveNameNull))); + } + + if (entity.SORT_NO <= 0) + { + //排序值不能小于等于0 + throw new Exception(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.ServiceProjectStatusSkuSaveSortNotEqualLessZero))); + } + + entity.IS_ENABLE = 1; + } + + if (entity == null) + { + //状态信息不能为空 + throw new Exception(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.ServiceProjectStatusSkuSaveModelNull))); + } + + Logger.Log(NLog.LogLevel.Info, $"服务项目保存 JSON={JsonConvert.SerializeObject(entity)} user={user.UserId}"); + + if (!string.IsNullOrWhiteSpace(info.StatusSKUCode)) + { + if (tenantDb.Queryable().Any(a => a.STATUS_SKU_CODE.Equals(info.StatusSKUCode) && a.PK_ID != info.PKId)) + { + Logger.Log(NLog.LogLevel.Info, $"状态代码已存在不能重复保存"); + + //状态代码已存在不能重复保存 + throw new Exception(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.ServiceProjectStatusSkuSaveCodeExists))); + } + } + + if (string.IsNullOrWhiteSpace(entity.PK_ID)) + { + tenantDb.Insertable(entity); + } + else + { + var model = InnerGetInfo(entity.PK_ID); + + Logger.Log(NLog.LogLevel.Info, $"更新状态前,获取原始记录 JSON={JsonConvert.SerializeObject(model)}"); + + ValidateServiceStatus(entity, TrackingOperateTypeEnum.Save); + + await tenantDb.Updateable(entity).ExecuteCommandAsync(); + } + + return DataResult.Success(entity.PK_ID); + } + #endregion + + #region 单票查询 + /// + /// 单票查询 + /// + /// 状态主键 + private StatusSkuBaseInfo InnerGetInfo(string id) + { + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + + if (string.IsNullOrWhiteSpace(id)) + { + //状态主键不能为空 + throw new Exception(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.ServiceProjectStatusSkuSaveIdNull))); + } + + var model = tenantDb.Queryable().First(a => a.PK_ID == id); + + if (model == null) + { + //状态获取失败,状态信息不存在或已作废 + throw new Exception(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.ServiceProjectStatusSkuEntityNull))); + } + + return model; + } + #endregion + + #region 校验 + /// + /// 校验 + /// + /// 服务状态详情 + /// 操作类型枚举 + /// + private void ValidateServiceStatus(StatusSkuBaseInfo entity, TrackingOperateTypeEnum opTypeEnum) + { + /* + 1、状态名称不能低于2个字符。 + 2、状态修改,需要判断当前状态是否关联服务的活动。已关联的不能修改状态代码。 + 3、取消启用时,需要判断当前状态是否关联服务的活动。已关联的不能取消启用。 + */ + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + + if (opTypeEnum == TrackingOperateTypeEnum.Save) + { + if (tenantDb.Queryable().Any(a => a.STATUS_SKU_ID == entity.PK_ID)) + { + //当前状态已关联服务流程活动,不能修改 + throw new Exception(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.ServiceProjectStatusSkuHasRelateWFAct))); + } + + if (entity.STATUS_SKU_CODE.Length < 2 || entity.STATUS_SKU_NAME.Length < 2) + { + //状态代码和状态名称不能小于2个字符,不能修改 + throw new Exception(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.ServiceProjectStatusSkuCodeNameLessTwoChar))); + } + } + + if (opTypeEnum == TrackingOperateTypeEnum.SetUnEnable) + { + if (tenantDb.Queryable().Any(a => a.STATUS_SKU_ID == entity.PK_ID)) + { + //当前状态已关联服务流程活动,不能取消启用 + throw new Exception(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.ServiceProjectStatusSkuHasRelateWFActNotSetUnEnable))); + } + } + + } + #endregion + + #region 保存并启用 + /// + /// 保存并启用 + /// + /// 状态详情 + /// 返回回执 + public async Task> SaveAndEnable(StatusSkuBaseDto info) + { + return await InnerSave(info, true); + } + #endregion + + #region 处理状态内部方法 + /// + /// 处理状态内部方法 + /// + /// 状态详情 + /// 操作类型 + /// 返回回执 + private async Task> InnerExcuteServiceStatus(StatusSkuBaseInfo model, TrackingOperateTypeEnum opTypeEnum) + { + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + + string name = model?.STATUS_SKU_NAME; + + try + { + if (model == null) + { + //状态获取失败,状态信息不存在或已作废 + throw new Exception(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.ServiceProjectStatusSkuEntityNull))); + } + + Logger.Log(NLog.LogLevel.Info, $"更新状态前,获取原始记录 JSON={JsonConvert.SerializeObject(model)}"); + + if (opTypeEnum == TrackingOperateTypeEnum.SetEnable) + { + if (string.IsNullOrWhiteSpace(model.STATUS_SKU_CODE) || string.IsNullOrWhiteSpace(model.STATUS_SKU_NAME)) + { + //状态代码或名称不能为空 + throw new Exception(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.ServiceProjectStatusSkuSaveNameNull))); + } + + if (model.SORT_NO <= 0) + { + //排序值不能小于等于0 + throw new Exception(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.ServiceProjectStatusSkuSaveSortNotEqualLessZero))); + } + + model.IS_ENABLE = 1; + model.UpdateBy = long.Parse(user.UserId); + model.UpdateUserName = user.UserName; + model.UpdateTime = DateTime.Now; + + await tenantDb.Updateable(model).UpdateColumns(it => new + { + it.IS_ENABLE, + it.UpdateBy, + it.UpdateUserName, + it.UpdateTime + + }).ExecuteCommandAsync(); + } + else if (opTypeEnum == TrackingOperateTypeEnum.SetUnEnable) + { + ValidateServiceStatus(model, opTypeEnum); + + model.IS_ENABLE = 0; + model.UpdateBy = long.Parse(user.UserId); + model.UpdateUserName = user.UserName; + model.UpdateTime = DateTime.Now; + + await tenantDb.Updateable(model).UpdateColumns(it => new + { + it.IS_ENABLE, + it.UpdateBy, + it.UpdateUserName, + it.UpdateTime + + }).ExecuteCommandAsync(); + } + else if (opTypeEnum == TrackingOperateTypeEnum.Delete) + { + ValidateServiceStatus(model, opTypeEnum); + + model.Deleted = true; + model.DeleteBy = long.Parse(user.UserId); + model.DeleteUserName = user.UserName; + model.DeleteTime = DateTime.Now; + + await tenantDb.Updateable(model).UpdateColumns(it => new + { + it.Deleted, + it.DeleteBy, + it.DeleteUserName, + it.DeleteTime + + }).ExecuteCommandAsync(); + } + } + catch (Exception ex) + { + Logger.Log(NLog.LogLevel.Info, $"执行失败,原因:{ex.Message}"); + + return DataResult.Failed($"执行失败,原因:{ex.Message}"); + } + + return DataResult.Success(name); + } + #endregion + + #region 启用 + /// + /// 启用 + /// + /// 状态主键数组 + /// 返回回执 + public async Task> SetEnable(string[] ids) + { + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + + string batchTotal = string.Empty; + try + { + if (ids.Length == 0) + { + //状态主键数组不能为空 + throw new Exception(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.ServiceProjectStatusSkuBatchIdsNull))); + } + + var list = tenantDb.Queryable() + .Where(a => ids.Contains(a.PK_ID)).ToList(); + + if (list.Count == 0) + { + //状态获取失败,请服务项目信息是否存在 + throw new Exception(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.ServiceProjectStatusSkuEntityNull))); + } + + if (list.Count != ids.Length) + { + //部分状态获取失败,请确认状态是否存在 + throw new Exception(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.ServiceProjectStatusSkuEntityPartNull))); + } + + List> rltList = new List>(); + + list.ForEach(pr => { + + rltList.Add(InnerExcuteServiceStatus(pr, TrackingOperateTypeEnum.SetEnable).GetAwaiter().GetResult()); + }); + + + + var succ = rltList.Count(x => x.Succeeded); + var fail = rltList.Count(x => !x.Succeeded); + + if (succ > 0) + { + batchTotal = succ.ToString(); + } + else + { + batchTotal = "- "; + } + + if (fail > 0) + { + batchTotal += "/" + fail.ToString(); + } + else + { + batchTotal += " -"; + } + } + catch (Exception ex) + { + Logger.Log(NLog.LogLevel.Info, $"启用状态异常,原因:{ex.Message}"); + + return DataResult.Failed($"启用状态异常,原因:{ex.Message}"); + } + + return DataResult.Success(batchTotal); + } + #endregion + + #region 取消启用 + /// + /// 取消启用 + /// + /// 状态主键数组 + /// 返回回执 + public async Task> SetUnEnable(string[] ids) + { + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + + string batchTotal = string.Empty; + try + { + if (ids.Length == 0) + { + //状态主键数组不能为空 + throw new Exception(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.ServiceProjectStatusSkuBatchIdsNull))); + } + + var list = tenantDb.Queryable() + .Where(a => ids.Contains(a.PK_ID)).ToList(); + + if (list.Count == 0) + { + //状态获取失败,请服务项目信息是否存在 + throw new Exception(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.ServiceProjectStatusSkuEntityNull))); + } + + if (list.Count != ids.Length) + { + //部分状态获取失败,请确认状态是否存在 + throw new Exception(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.ServiceProjectStatusSkuEntityPartNull))); + } + + List> rltList = new List>(); + + list.ForEach(pr => { + + rltList.Add(InnerExcuteServiceStatus(pr, TrackingOperateTypeEnum.SetUnEnable).GetAwaiter().GetResult()); + }); + + var succ = rltList.Count(x => x.Succeeded); + var fail = rltList.Count(x => !x.Succeeded); + + if (succ > 0) + { + batchTotal = succ.ToString(); + } + else + { + batchTotal = "- "; + } + + if (fail > 0) + { + batchTotal += "/" + fail.ToString(); + } + else + { + batchTotal += " -"; + } + } + catch (Exception ex) + { + Logger.Log(NLog.LogLevel.Info, $"取消启用状态异常,原因:{ex.Message}"); + + return DataResult.Failed($"取消启用状态异常,原因:{ex.Message}"); + } + + return DataResult.Success(batchTotal); + } + #endregion + + #region 删除 + /// + /// 删除 + /// + /// 状态主键数组 + /// 返回回执 + public async Task> Delete(string[] ids) + { + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + + string batchTotal = string.Empty; + try + { + if (ids.Length == 0) + { + //状态主键数组不能为空 + throw new Exception(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.ServiceProjectStatusSkuBatchIdsNull))); + } + + var list = tenantDb.Queryable() + .Where(a => ids.Contains(a.PK_ID)).ToList(); + + if (list.Count == 0) + { + //状态获取失败,请服务项目信息是否存在 + throw new Exception(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.ServiceProjectStatusSkuEntityNull))); + } + + if (list.Count != ids.Length) + { + //部分状态获取失败,请确认状态是否存在 + throw new Exception(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.ServiceProjectStatusSkuEntityPartNull))); + } + + List> rltList = new List>(); + + list.ForEach(pr => { + + rltList.Add(InnerExcuteServiceStatus(pr, TrackingOperateTypeEnum.Delete).GetAwaiter().GetResult()); + }); + + var succ = rltList.Count(x => x.Succeeded); + var fail = rltList.Count(x => !x.Succeeded); + + if (succ > 0) + { + batchTotal = succ.ToString(); + } + else + { + batchTotal = "- "; + } + + if (fail > 0) + { + batchTotal += "/" + fail.ToString(); + } + else + { + batchTotal += " -"; + } + } + catch (Exception ex) + { + Logger.Log(NLog.LogLevel.Info, $"删除状态异常,原因:{ex.Message}"); + + return DataResult.Failed($"删除状态异常,原因:{ex.Message}"); + } + + return DataResult.Success(batchTotal); + } + #endregion + + #region 获取状态详情 + /// + /// 获取状态详情 + /// + /// 状态主键 + /// 返回回执 + public async Task> GetInfo(string id) + { + var model = InnerGetInfo(id); + + var showModel = model.Adapt(); + + return DataResult.Success(showModel); + } + #endregion + + #region 检索状态列表 + /// + /// 检索状态列表 + /// + /// 检索值 + /// 最大返回行数(默认15) + /// 返回回执 + public async Task>> QueryList(string queryItem, int topNum = 15) + { + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + + var list = await tenantDb.Queryable().Where(a => a.IS_ENABLE == 1 && a.Deleted == false) + .WhereIF(!string.IsNullOrWhiteSpace(queryItem), a => (a.STATUS_SKU_CODE.Contains(queryItem) || a.STATUS_SKU_NAME.Contains(queryItem))) + .Take(topNum).ToListAsync(); + + var rltList = list.Adapt>(); + + return DataResult>.Success(rltList); + } + #endregion + + #region 状态台账查询 + /// + /// 状态台账查询 + /// + /// 状态台账查询请求 + /// 返回结果 + public async Task>> GetPageAsync(PageRequest querySearch) + { + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + + List whereList = null; + + StatusSkuBaseQueryExtDto otherQueryCondition = new StatusSkuBaseQueryExtDto(); + + whereList = GetPageCondition(querySearch, out otherQueryCondition); + + + var query = tenantDb.Queryable() + .Where(whereList) + .WhereIF(otherQueryCondition != null && !string.IsNullOrWhiteSpace(otherQueryCondition.StatusSKUName), a => + a.STATUS_SKU_CODE.Contains(otherQueryCondition.StatusSKUName) || a.STATUS_SKU_NAME.Contains(otherQueryCondition.StatusSKUName)) + .WhereIF(otherQueryCondition != null && !string.IsNullOrWhiteSpace(otherQueryCondition.StatusSKUNote), a => + a.STATUS_SKU_NOTE.Contains(otherQueryCondition.StatusSKUName)) + .WhereIF(otherQueryCondition != null && otherQueryCondition.CreateStart.HasValue, a => a.CreateTime >= otherQueryCondition.CreateStart) + .WhereIF(otherQueryCondition != null && otherQueryCondition.CreateEnd.HasValue, a => a.CreateTime < otherQueryCondition.CreateEnd) + .WhereIF(otherQueryCondition != null && otherQueryCondition.UpdateStart.HasValue, a => a.UpdateTime >= otherQueryCondition.UpdateStart) + .WhereIF(otherQueryCondition != null && otherQueryCondition.UpdateEnd.HasValue, a => a.UpdateTime < otherQueryCondition.UpdateEnd); + + if (whereList != null) + { + query = query.Where(whereList); + } + + var result = await query.ToQueryPageAsync(querySearch.PageCondition); + + List resultList = new List(); + + if (result.Data.Count > 0) + { + resultList = result.Data.Adapt>(); + } + + return DataResult>.PageList(result.Count, resultList, MultiLanguageConst.DataQuerySuccess); + } + #endregion + + #region 获取台账查询条件 + /// + /// 获取台账查询条件 + /// + /// 原始查询条件 + /// 其他查询条件 + /// + private List GetPageCondition(PageRequest querySearch, out StatusSkuBaseQueryExtDto queryExt) + { + List whereList = null; + + queryExt = new StatusSkuBaseQueryExtDto(); + + if (!string.IsNullOrWhiteSpace(querySearch.OtherQueryCondition)) + { + queryExt = JsonConvert.DeserializeObject(querySearch.OtherQueryCondition); + } + + if (!string.IsNullOrWhiteSpace(querySearch.QueryCondition)) + { + whereList = querySearch.GetConditionalModels(db); + + #region 处理查询条件 + if (whereList.Any(t => ((ConditionalModel)t).FieldName.Equals("StatusSKUName", StringComparison.OrdinalIgnoreCase))) + { + var t = whereList.FirstOrDefault(t => ((ConditionalModel)t).FieldName.Equals("StatusSKUName", StringComparison.OrdinalIgnoreCase)); + queryExt.StatusSKUName = ((ConditionalModel)t).FieldValue; + + whereList.Remove(t); + } + + if (whereList.Any(t => ((ConditionalModel)t).FieldName.Equals("StatusSKUNote", StringComparison.OrdinalIgnoreCase))) + { + var t = whereList.FirstOrDefault(t => ((ConditionalModel)t).FieldName.Equals("StatusSKUNote", StringComparison.OrdinalIgnoreCase)); + queryExt.StatusSKUNote = ((ConditionalModel)t).FieldValue; + + whereList.Remove(t); + } + + if (whereList.Any(t => ((ConditionalModel)t).FieldName.Equals("CreateBy", StringComparison.OrdinalIgnoreCase))) + { + var t = whereList.FirstOrDefault(t => ((ConditionalModel)t).FieldName.Equals("CreateBy", StringComparison.OrdinalIgnoreCase)); + queryExt.CreateBy = long.Parse(((ConditionalModel)t).FieldValue); + + whereList.Remove(t); + } + + if (whereList.Any(t => ((ConditionalModel)t).FieldName.Equals("UpdateBy", StringComparison.OrdinalIgnoreCase))) + { + var t = whereList.FirstOrDefault(t => ((ConditionalModel)t).FieldName.Equals("UpdateBy", StringComparison.OrdinalIgnoreCase)); + queryExt.UpdateBy = long.Parse(((ConditionalModel)t).FieldValue); + + whereList.Remove(t); + } + + if (whereList.Any(t => ((ConditionalModel)t).FieldName.Equals("CreateTime", StringComparison.OrdinalIgnoreCase))) + { + var curList = whereList.Where(t => ((ConditionalModel)t).FieldName.Equals("CreateTime", StringComparison.OrdinalIgnoreCase)).ToList(); + + foreach (ConditionalModel b in curList) + { + if (b.ConditionalType == ConditionalType.GreaterThanOrEqual) + { + DateTime currDate = DateTime.MinValue; + if (DateTime.TryParse(b.FieldValue, out currDate)) + { + queryExt.CreateStart = currDate; + } + } + else if (b.ConditionalType == ConditionalType.LessThanOrEqual) + { + DateTime currDate = DateTime.MinValue; + if (DateTime.TryParse(b.FieldValue, out currDate)) + { + queryExt.CreateEnd = currDate.AddDays(1); + } + } + + whereList.Remove(b); + } + } + + if (whereList.Any(t => ((ConditionalModel)t).FieldName.Equals("UpdateTime", StringComparison.OrdinalIgnoreCase))) + { + var curList = whereList.Where(t => ((ConditionalModel)t).FieldName.Equals("UpdateTime", StringComparison.OrdinalIgnoreCase)).ToList(); + + foreach (ConditionalModel b in curList) + { + if (b.ConditionalType == ConditionalType.GreaterThanOrEqual) + { + DateTime currDate = DateTime.MinValue; + if (DateTime.TryParse(b.FieldValue, out currDate)) + { + queryExt.UpdateStart = currDate; + } + } + else if (b.ConditionalType == ConditionalType.LessThanOrEqual) + { + DateTime currDate = DateTime.MinValue; + if (DateTime.TryParse(b.FieldValue, out currDate)) + { + queryExt.UpdateEnd = currDate.AddDays(1); + } + } + + whereList.Remove(b); + } + } + #endregion + } + + return whereList; + } + #endregion + } +} diff --git a/ds-wms-service/DS.WMS.Core/TaskPlat/Dtos/Mapper/AddTaskPlatMapsterSetup.cs b/ds-wms-service/DS.WMS.Core/TaskPlat/Dtos/Mapper/AddTaskPlatMapsterSetup.cs index a5653017..4eb67a6e 100644 --- a/ds-wms-service/DS.WMS.Core/TaskPlat/Dtos/Mapper/AddTaskPlatMapsterSetup.cs +++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Dtos/Mapper/AddTaskPlatMapsterSetup.cs @@ -852,6 +852,86 @@ namespace DS.WMS.Core.TaskPlat.Dtos.Mapper //.Map(dest => dest.LstStatusName, src => src.LST_STATUS_NAME); } + + { + TypeAdapterConfig.NewConfig() + .Map(dest => dest.Id, src => src.Id) + .Map(dest => dest.SERVICE_PROJECT_CODE, src => src.ServiceProjectCode) + .Map(dest => dest.SERVICE_PROJECT_NAME, src => src.ServiceProjectName) + .Map(dest => dest.SORT_NO, src => src.SortNo) + .Map(dest => dest.SERVICE_PROJECT_NOTE, src => src.ServiceProjectNote); + } + + { + TypeAdapterConfig.NewConfig() + .Map(dest => dest.Id, src => src.Id) + .Map(dest => dest.ServiceProjectCode, src => src.SERVICE_PROJECT_CODE) + .Map(dest => dest.ServiceProjectName, src => src.SERVICE_PROJECT_NAME) + .Map(dest => dest.SortNo, src => src.SORT_NO); + } + + { + TypeAdapterConfig.NewConfig() + .Map(dest => dest.PK_ID, src => src.PKId) + .Map(dest => dest.STATUS_SKU_CODE, src => src.StatusSKUCode) + .Map(dest => dest.STATUS_SKU_NAME, src => src.StatusSKUName) + .Map(dest => dest.SORT_NO, src => src.SortNo) + .Map(dest => dest.STATUS_SKU_NOTE, src => src.StatusSKUNote) + .Map(dest => dest.BACKGROUND_COLOR, src => src.BackgroundColor); + } + + { + TypeAdapterConfig.NewConfig() + .Map(dest => dest.PKId, src => src.PK_ID) + .Map(dest => dest.StatusSKUCode, src => src.STATUS_SKU_CODE) + .Map(dest => dest.StatusSKUName, src => src.STATUS_SKU_NAME) + .Map(dest => dest.SortNo, src => src.SORT_NO); + } + + { + TypeAdapterConfig.NewConfig() + .Map(dest => dest.SkuPKId, src => src.PK_ID) + .Map(dest => dest.StatusSKUCode, src => src.STATUS_SKU_CODE) + .Map(dest => dest.StatusSKUName, src => src.STATUS_SKU_NAME) + .Map(dest => dest.SortNo, src => src.SORT_NO) + .Map(dest => dest.BackgroundColor, src => src.BACKGROUND_COLOR); + } + + { + TypeAdapterConfig.NewConfig() + .Map(dest => dest.PKId, src => src.PK_ID) + .Map(dest => dest.StatusSKUCode, src => src.STATUS_SKU_CODE) + .Map(dest => dest.StatusSKUName, src => src.STATUS_SKU_NAME) + .Map(dest => dest.SortNo, src => src.SORT_NO) + .Map(dest => dest.IsEnable, src => src.IS_ENABLE) + .Map(dest => dest.CreatedTime, src => src.CreateTime) + .Map(dest => dest.UpdatedTime, src => src.UpdateTime) + .Map(dest => dest.CreatedUserId, src => src.CreateBy) + .Map(dest => dest.CreatedUserName, src => src.CreateUserName) + .Map(dest => dest.UpdatedUserId, src => src.UpdateBy) + .Map(dest => dest.UpdatedUserName, src => src.UpdateUserName) + .Map(dest => dest.StatusSKUNote, src => src.STATUS_SKU_NOTE) + .Map(dest => dest.IsEnable, src => src.IS_ENABLE) + .Map(dest => dest.BackgroundColor, src => src.BACKGROUND_COLOR); + } + + { + TypeAdapterConfig.NewConfig() + .Map(dest => dest.PKId, src => src.PK_ID) + .Map(dest => dest.StatusSKUCode, src => src.STATUS_SKU_CODE) + .Map(dest => dest.StatusSKUName, src => src.STATUS_SKU_NAME) + .Map(dest => dest.SortNo, src => src.SORT_NO) + .Map(dest => dest.CreatedTime, src => src.CreateTime) + .Map(dest => dest.UpdatedTime, src => src.UpdateTime) + .Map(dest => dest.CreatedUserId, src => src.CreateBy) + .Map(dest => dest.CreatedUserName, src => src.CreateUserName) + .Map(dest => dest.UpdatedUserId, src => src.UpdateBy) + .Map(dest => dest.UpdatedUserName, src => src.UpdateUserName) + .Map(dest => dest.StatusSKUNote, src => src.STATUS_SKU_NOTE) + .Map(dest => dest.IsEnable, src => src.IS_ENABLE) + .Map(dest => dest.BackgroundColor, src => src.BACKGROUND_COLOR); + } + } } }