修改服务项目的状态管理

dev
jianghaiqing 2 weeks ago
parent 0e0530b2b6
commit 0ab7806ce0

@ -1744,4 +1744,73 @@ public static class MultiLanguageConst
[Description("还存在未处理上线状态的导入明细")]
public const string CM_NoDealTempDetail = "Exists some Detail need to deal.";
#endregion
#region 服务项目
/// <summary>
/// 状态代码或名称不能为空
/// </summary>
[Description("状态代码或名称不能为空")]
public const string ServiceProjectStatusSkuSaveNameNull = "ServiceProject_StatusSku_SaveNameNull";
/// <summary>
/// 排序值不能小于等于0
/// </summary>
[Description("排序值不能小于等于0")]
public const string ServiceProjectStatusSkuSaveSortNotEqualLessZero = "ServiceProject_StatusSku_SaveSortNotEqualLessZero";
/// <summary>
/// 状态信息不能为空
/// </summary>
[Description("状态信息不能为空")]
public const string ServiceProjectStatusSkuSaveModelNull = "ServiceProject_StatusSku_SaveModelNull";
/// <summary>
/// 状态代码已存在不能重复保存
/// </summary>
[Description("状态代码已存在不能重复保存")]
public const string ServiceProjectStatusSkuSaveCodeExists = "ServiceProject_StatusSku_SaveCodeExists";
/// <summary>
/// 状态主键不能为空
/// </summary>
[Description("状态主键不能为空")]
public const string ServiceProjectStatusSkuSaveIdNull = "ServiceProject_StatusSku_SaveIdNull";
/// <summary>
/// 状态获取失败,状态信息不存在或已作废
/// </summary>
[Description("状态获取失败,状态信息不存在或已作废")]
public const string ServiceProjectStatusSkuEntityNull = "ServiceProject_StatusSku_EntityNull";
/// <summary>
/// 当前状态已关联服务流程活动,不能修改
/// </summary>
[Description("当前状态已关联服务流程活动,不能修改")]
public const string ServiceProjectStatusSkuHasRelateWFAct = "ServiceProject_StatusSku_HasRelateWFAct";
/// <summary>
/// 状态代码和状态名称不能小于2个字符不能修改
/// </summary>
[Description("状态代码和状态名称不能小于2个字符不能修改")]
public const string ServiceProjectStatusSkuCodeNameLessTwoChar = "ServiceProject_StatusSku_HasRelateWFAct";
/// <summary>
/// 当前状态已关联服务流程活动,不能取消启用
/// </summary>
[Description("当前状态已关联服务流程活动,不能取消启用")]
public const string ServiceProjectStatusSkuHasRelateWFActNotSetUnEnable = "ServiceProject_StatusSku_HasRelateWFActNotSetUnEnable";
/// <summary>
/// 状态主键数组不能为空
/// </summary>
[Description("状态主键数组不能为空")]
public const string ServiceProjectStatusSkuBatchIdsNull = "ServiceProject_StatusSku_BatchIdsNull";
/// <summary>
/// 部分状态获取失败,请确认状态是否存在
/// </summary>
[Description("部分状态获取失败,请确认状态是否存在")]
public const string ServiceProjectStatusSkuEntityPartNull = "ServiceProject_StatusSku_EntityPartNull";
#endregion
}

@ -43,7 +43,6 @@
<Folder Include="Op\Interface\TaskInteraction\" />
<Folder Include="Op\Interface\新文件夹\" />
<Folder Include="Op\Method\TaskInteraction\" />
<Folder Include="Op\Method\ServiceProject\" />
</ItemGroup>
<ItemGroup>

@ -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
{
/// <summary>
/// 服务项目操作类型枚举
/// </summary>
public enum TrackingOperateTypeEnum
{
/// <summary>
/// 保存
/// </summary>
[Description("保存")]
Save,
/// <summary>
/// 提交
/// </summary>
[Description("提交")]
Submit,
/// <summary>
/// 取消
/// </summary>
[Description("取消")]
Cancel,
/// <summary>
/// 删除
/// </summary>
[Description("删除")]
Delete,
/// <summary>
/// 派车
/// </summary>
[Description("派车")]
SendDispatch,
/// <summary>
/// 取消派车
/// </summary>
[Description("取消派车")]
CancelDispatch,
/// <summary>
/// 派车回写详情
/// </summary>
[Description("派车回写详情")]
DispatchBackSave,
/// <summary>
/// 设定启用
/// </summary>
[Description("设定启用")]
SetEnable,
/// <summary>
/// 设定不启用
/// </summary>
[Description("设定不启用")]
SetUnEnable
}
}

@ -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
{
/// <summary>
/// 服务项目状态台账查询扩展
/// </summary>
public class StatusSkuBaseQueryExtDto
{
/// <summary>
/// 创建起始时间
/// </summary>
public Nullable<DateTime> CreateStart { get; set; }
/// <summary>
/// 创建结束时间
/// </summary>
public Nullable<DateTime> CreateEnd { get; set; }
/// <summary>
/// 更新起始时间
/// </summary>
public Nullable<DateTime> UpdateStart { get; set; }
/// <summary>
/// 更新结束时间
/// </summary>
public Nullable<DateTime> UpdateEnd { get; set; }
/// <summary>
/// 是否启用 1-已启用 2-未启用
/// </summary>
/// <example></example>
public string IsEnable { get; set; }
/// <summary>
/// 状态名称
/// </summary>
public string StatusSKUName { get; set; }
/// <summary>
/// 状态说明
/// </summary>
public string StatusSKUNote { get; set; }
/// <summary>
/// 创建人
/// </summary>
public Nullable<long> CreateBy { get; set; }
/// <summary>
/// 更新人
/// </summary>
public Nullable<long> UpdateBy { get; set; }
}
}

@ -15,20 +15,22 @@ namespace DS.WMS.Core.Op.Dtos
{
public void Register(TypeAdapterConfig config)
{
/*
config.ForType<ServiceProjectBaseDto, ServiceProjectBaseInfo>()
.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<ServiceProjectBaseInfo, ServiceProjectBaseDto>()
.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<ServiceProjectBaseInfo, ServiceProjectBaseShowDto>()
.Map(dest => dest.PKId, src => src.PK_ID)
.Map(dest => dest.ServiceProjectCode, src => src.SERVICE_PROJECT_CODE)

@ -13,8 +13,14 @@ namespace DS.WMS.Core.Op.Entity
/// 状态主表
/// </summary>
[SqlSugar.SugarTable("status_sku_base", "状态主表")]
public class StatusSkuBaseInfo : BaseModelV2<long>
public class StatusSkuBaseInfo
{
/// <summary>
/// 主键
/// </summary>
[SugarColumn(ColumnDescription = "主键", IsPrimaryKey = true)]
public string PK_ID { get; set; }
/// <summary>
/// 状态代码
/// </summary>
@ -44,5 +50,75 @@ namespace DS.WMS.Core.Op.Entity
/// 状态说明
/// </summary>
public string STATUS_SKU_NOTE { get; set; }
/// <summary>
/// 创建时间
/// </summary>
[Description("创建时间")]
[SugarColumn(IsOnlyIgnoreUpdate = true, ColumnDescription = "创建时间")]
public DateTime CreateTime { get; set; }
/// <summary>
/// 创建人
/// </summary>
[Description("创建人")]
[SugarColumn(IsOnlyIgnoreUpdate = true, IsNullable = true, ColumnDescription = "创建人")]
public long CreateBy { get; set; }
/// <summary>
/// 修改人
/// </summary>
[Description("修改人")]
[SugarColumn(IsNullable = true, ColumnDescription = "修改人")]
public long? UpdateBy { get; set; }
/// <summary>
/// 更新时间
/// </summary>
[Description("更新时间")]
[SugarColumn(IsNullable = true, ColumnDescription = "更新时间")]
public Nullable<DateTime> UpdateTime { get; set; }
/// <summary>
/// 删除
/// </summary>
[Description("删除")]
[SugarColumn(ColumnDescription = "是否删除", DefaultValue = "0")]
public bool Deleted { get; set; }
/// <summary>
/// 删除时间
/// </summary>
[Description("删除时间")]
[SugarColumn(IsNullable = true, ColumnDescription = "删除时间", IsOnlyIgnoreInsert = true)]
public Nullable<DateTime> DeleteTime { get; set; }
/// <summary>
/// 删除人
/// </summary>
[Description("删除人")]
[SugarColumn(IsNullable = true, ColumnDescription = "删除人", IsOnlyIgnoreInsert = true)]
public Nullable<long> DeleteBy { get; set; }
/// <summary>
/// 创建人名称
/// </summary>
[Description("创建人名称")]
[SugarColumn(IsOnlyIgnoreUpdate = true, IsNullable = true, ColumnDescription = "创建人名称", Length = 50)]
public string CreateUserName { get; set; }
/// <summary>
/// 修改人名称
/// </summary>
[Description("修改人名称")]
[SugarColumn(IsNullable = true, ColumnDescription = "修改人名称", Length = 50)]
public string UpdateUserName { get; set; }
/// <summary>
/// 删除人名称
/// </summary>
[Description("删除人名称")]
[SugarColumn(IsNullable = true, ColumnDescription = "删除人名称", Length = 50, IsOnlyIgnoreInsert = true)]
public string DeleteUserName { get; set; }
}
}

@ -18,42 +18,42 @@ namespace Myshipping.Application
/// </summary>
/// <param name="info">状态详情</param>
/// <returns>返回回执</returns>
Task<DataResult<long>> Save(StatusSkuBaseDto info);
Task<DataResult<string>> Save(StatusSkuBaseDto info);
/// <summary>
/// 保存并启用
/// </summary>
/// <param name="info">状态详情</param>
/// <returns>返回回执</returns>
Task<DataResult<long>> SaveAndEnable(StatusSkuBaseDto info);
Task<DataResult<string>> SaveAndEnable(StatusSkuBaseDto info);
/// <summary>
/// 启用
/// </summary>
/// <param name="pkIds">状态主键数组</param>
/// <param name="ids">状态主键数组</param>
/// <returns>返回回执</returns>
Task<DataResult<string>> SetEnable(string[] pkIds);
Task<DataResult<string>> SetEnable(string[] ids);
/// <summary>
/// 取消启用
/// </summary>
/// <param name="pkIds">状态主键数组</param>
/// <param name="ids">状态主键数组</param>
/// <returns>返回回执</returns>
Task<DataResult<string>> SetUnEnable(string[] pkIds);
Task<DataResult<string>> SetUnEnable(string[] ids);
/// <summary>
/// 删除
/// </summary>
/// <param name="pkIds">状态主键数组</param>
/// <param name="ids">状态主键数组</param>
/// <returns>返回回执</returns>
Task<DataResult<string>> Delete(string[] pkIds);
Task<DataResult<string>> Delete(string[] ids);
/// <summary>
/// 获取状态详情
/// </summary>
/// <param name="pkId">状态主键</param>
/// <param name="id">状态主键</param>
/// <returns>返回回执</returns>
Task<DataResult<StatusSkuBaseShowDto>> GetInfo(string pkId);
Task<DataResult<StatusSkuBaseShowDto>> GetInfo(string id);
/// <summary>
/// 检索状态列表
@ -66,9 +66,9 @@ namespace Myshipping.Application
/// <summary>
/// 状态台账查询
/// </summary>
/// <param name="QuerySearch">状态台账查询请求</param>
/// <param name="querySearch">状态台账查询请求</param>
/// <returns>返回结果</returns>
Task<SqlSugarPagedList<StatusSkuBasePageDto>> GetPageAsync(QueryStatusSkuBaseDto QuerySearch);
Task<DataResult<List<StatusSkuBasePageDto>>> GetPageAsync(PageRequest querySearch);
}
}

@ -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
{
/// <summary>
/// 状态管理
/// </summary>
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<ISqlSugarClient>();
user = _serviceProvider.GetRequiredService<IUser>();
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
}
#region 保存
/// <summary>
/// 保存
/// </summary>
/// <param name="info">状态详情</param>
/// <returns>返回回执</returns>
public async Task<DataResult<string>> Save([FromBody] StatusSkuBaseDto info)
{
return await InnerSave(info);
}
#endregion
#region 保存内部方法
/// <summary>
/// 保存内部方法
/// </summary>
/// <param name="info">服务项目详情</param>
/// <param name="isSetEnable">是否启用</param>
/// <returns>返回派车Id</returns>
private async Task<DataResult<string>> InnerSave(StatusSkuBaseDto info, bool isSetEnable = false)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
StatusSkuBaseInfo entity = info.Adapt<StatusSkuBaseInfo>();
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<StatusSkuBaseInfo>().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<StatusSkuBaseInfo>(entity);
}
else
{
var model = InnerGetInfo(entity.PK_ID);
Logger.Log(NLog.LogLevel.Info, $"更新状态前,获取原始记录 JSON={JsonConvert.SerializeObject(model)}");
ValidateServiceStatus(entity, TrackingOperateTypeEnum.Save);
await tenantDb.Updateable<StatusSkuBaseInfo>(entity).ExecuteCommandAsync();
}
return DataResult<string>.Success(entity.PK_ID);
}
#endregion
#region 单票查询
/// <summary>
/// 单票查询
/// </summary>
/// <param name="id">状态主键</param>
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<StatusSkuBaseInfo>().First(a => a.PK_ID == id);
if (model == null)
{
//状态获取失败,状态信息不存在或已作废
throw new Exception(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.ServiceProjectStatusSkuEntityNull)));
}
return model;
}
#endregion
#region 校验
/// <summary>
/// 校验
/// </summary>
/// <param name="entity">服务状态详情</param>
/// <param name="opTypeEnum">操作类型枚举</param>
/// <returns></returns>
private void ValidateServiceStatus(StatusSkuBaseInfo entity, TrackingOperateTypeEnum opTypeEnum)
{
/*
12
2
3
*/
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
if (opTypeEnum == TrackingOperateTypeEnum.Save)
{
if (tenantDb.Queryable<ServiceWorkFlowActivitiesInfo>().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<ServiceWorkFlowActivitiesInfo>().Any(a => a.STATUS_SKU_ID == entity.PK_ID))
{
//当前状态已关联服务流程活动,不能取消启用
throw new Exception(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.ServiceProjectStatusSkuHasRelateWFActNotSetUnEnable)));
}
}
}
#endregion
#region 保存并启用
/// <summary>
/// 保存并启用
/// </summary>
/// <param name="info">状态详情</param>
/// <returns>返回回执</returns>
public async Task<DataResult<string>> SaveAndEnable(StatusSkuBaseDto info)
{
return await InnerSave(info, true);
}
#endregion
#region 处理状态内部方法
/// <summary>
/// 处理状态内部方法
/// </summary>
/// <param name="model">状态详情</param>
/// <param name="opTypeEnum">操作类型</param>
/// <returns>返回回执</returns>
private async Task<DataResult<string>> 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<string>.Failed($"执行失败,原因:{ex.Message}");
}
return DataResult<string>.Success(name);
}
#endregion
#region 启用
/// <summary>
/// 启用
/// </summary>
/// <param name="ids">状态主键数组</param>
/// <returns>返回回执</returns>
public async Task<DataResult<string>> 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<StatusSkuBaseInfo>()
.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<DataResult<string>> rltList = new List<DataResult<string>>();
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<string>.Failed($"启用状态异常,原因:{ex.Message}");
}
return DataResult<string>.Success(batchTotal);
}
#endregion
#region 取消启用
/// <summary>
/// 取消启用
/// </summary>
/// <param name="ids">状态主键数组</param>
/// <returns>返回回执</returns>
public async Task<DataResult<string>> 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<StatusSkuBaseInfo>()
.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<DataResult<string>> rltList = new List<DataResult<string>>();
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<string>.Failed($"取消启用状态异常,原因:{ex.Message}");
}
return DataResult<string>.Success(batchTotal);
}
#endregion
#region 删除
/// <summary>
/// 删除
/// </summary>
/// <param name="ids">状态主键数组</param>
/// <returns>返回回执</returns>
public async Task<DataResult<string>> 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<StatusSkuBaseInfo>()
.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<DataResult<string>> rltList = new List<DataResult<string>>();
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<string>.Failed($"删除状态异常,原因:{ex.Message}");
}
return DataResult<string>.Success(batchTotal);
}
#endregion
#region 获取状态详情
/// <summary>
/// 获取状态详情
/// </summary>
/// <param name="pkId">状态主键</param>
/// <returns>返回回执</returns>
public async Task<DataResult<StatusSkuBaseShowDto>> GetInfo(string id)
{
var model = InnerGetInfo(id);
var showModel = model.Adapt<StatusSkuBaseShowDto>();
return DataResult<StatusSkuBaseShowDto>.Success(showModel);
}
#endregion
#region 检索状态列表
/// <summary>
/// 检索状态列表
/// </summary>
/// <param name="queryItem">检索值</param>
/// <param name="topNum">最大返回行数默认15</param>
/// <returns>返回回执</returns>
public async Task<DataResult<List<StatusSkuBaseDto>>> QueryList(string queryItem, int topNum = 15)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var list = await tenantDb.Queryable<StatusSkuBaseInfo>().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<List<StatusSkuBaseDto>>();
return DataResult<List<StatusSkuBaseDto>>.Success(rltList);
}
#endregion
#region 状态台账查询
/// <summary>
/// 状态台账查询
/// </summary>
/// <param name="QuerySearch">状态台账查询请求</param>
/// <returns>返回结果</returns>
public async Task<DataResult<List<StatusSkuBasePageDto>>> GetPageAsync(PageRequest querySearch)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
List<IConditionalModel> whereList = null;
StatusSkuBaseQueryExtDto otherQueryCondition = new StatusSkuBaseQueryExtDto();
whereList = GetPageCondition(querySearch, out otherQueryCondition);
var query = tenantDb.Queryable<StatusSkuBaseInfo>()
.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<StatusSkuBasePageDto> resultList = new List<StatusSkuBasePageDto>();
if (result.Data.Count > 0)
{
resultList = result.Data.Adapt<List<StatusSkuBasePageDto>>();
}
return DataResult<List<StatusSkuBasePageDto>>.PageList(result.Count, resultList, MultiLanguageConst.DataQuerySuccess);
}
#endregion
#region 获取台账查询条件
/// <summary>
/// 获取台账查询条件
/// </summary>
/// <param name="querySearch">原始查询条件</param>
/// <param name="queryExt">其他查询条件</param>
/// <returns></returns>
private List<IConditionalModel> GetPageCondition(PageRequest querySearch, out StatusSkuBaseQueryExtDto queryExt)
{
List<IConditionalModel> whereList = null;
queryExt = new StatusSkuBaseQueryExtDto();
if (!string.IsNullOrWhiteSpace(querySearch.OtherQueryCondition))
{
queryExt = JsonConvert.DeserializeObject<StatusSkuBaseQueryExtDto>(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
}
}

@ -852,6 +852,86 @@ namespace DS.WMS.Core.TaskPlat.Dtos.Mapper
//.Map(dest => dest.LstStatusName, src => src.LST_STATUS_NAME);
}
{
TypeAdapterConfig<ServiceProjectBaseDto, ServiceProjectBaseInfo>.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<ServiceProjectBaseInfo, ServiceProjectBaseDto>.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<StatusSkuBaseDto, StatusSkuBaseInfo>.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<StatusSkuBaseInfo, StatusSkuBaseDto>.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<StatusSkuBaseInfo, ServiceProjectStatusDto>.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<StatusSkuBaseInfo, StatusSkuBaseShowDto>.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<StatusSkuBaseInfo, StatusSkuBasePageDto>.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);
}
}
}
}

Loading…
Cancel
Save