Commit dbe68afe by zhoujinhui

修改盘点功能

parent ffc72d4b
......@@ -4,4 +4,13 @@
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
<PackageReference Include="Qiniu.SDK" Version="8.0.0" />
</ItemGroup>
</Project>
using Microsoft.Extensions.Configuration;
using System.Collections.Concurrent;
namespace Common
{
public static class Configurations
{
private static readonly ConcurrentDictionary<string, IConfigurationRoot> ConfigurationCache;
static Configurations()
{
ConfigurationCache = new ConcurrentDictionary<string, IConfigurationRoot>();
}
public static IConfigurationRoot Get(string path, string environmentName = null)
{
var cacheKey = path + "#" + environmentName;
return ConfigurationCache.GetOrAdd(
cacheKey,
_ => BuildConfiguration(path, environmentName)
);
}
private static IConfigurationRoot BuildConfiguration(string path, string environmentName = null)
{
var builder = new ConfigurationBuilder()
.SetBasePath(path)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
if (!string.IsNullOrWhiteSpace(environmentName))
{
builder = builder.AddJsonFile($"appsettings.{environmentName}.json", optional: true);
}
builder = builder.AddEnvironmentVariables();
return builder.Build();
}
}
}
using System;
using System.IO;
using System.Linq;
namespace Common
{
/// <summary>
/// This class is used to find root path of the web project in;
/// unit tests (to find views) and entity framework core command line commands (to find conn string).
/// </summary>
public static class DirectoryFinder
{
public static string CalculateContentRootFolder()
{
var coreAssemblyDirectoryPath = Path.GetDirectoryName(AppContext.BaseDirectory);
if (coreAssemblyDirectoryPath.Contains("WindowService"))
{
return coreAssemblyDirectoryPath;
}
if (coreAssemblyDirectoryPath == null)
{
throw new Exception("Could not find location of main assembly!");
}
var directoryInfo = new DirectoryInfo(coreAssemblyDirectoryPath);
while (!DirectoryContains(directoryInfo.FullName, "appsettings.json"))
{
if (directoryInfo.Parent == null)
{
throw new Exception("Could not find content root folder!");
}
directoryInfo = directoryInfo.Parent;
}
return directoryInfo.FullName;
}
private static bool DirectoryContains(string directory, string fileName)
{
return Directory.GetFiles(directory).Any(filePath => string.Equals(Path.GetFileName(filePath), fileName));
}
}
}
using System;
namespace Common.Extensions
{
public static class DateTimeExtensions
{
/// <summary>
/// 格式化时间
/// </summary>
/// <param name="dateTime"></param>
/// <returns></returns>
public static string ToLongStr(this DateTime dateTime)
{
return dateTime.ToString("yyyy-MM-dd HH:mm:ss");
}
}
}
using System;
using System.ComponentModel;
using System.Reflection;
namespace Common.Extensions
{
public static class EnumExtensions
{
/// <summary>
/// 获取描述信息
/// </summary>
/// <param name="en"></param>
/// <returns></returns>
public static string GetEnumDes(this Enum en)
{
Type type = en.GetType();
MemberInfo[] memInfo = type.GetMember(en.ToString());
if (memInfo != null && memInfo.Length > 0)
{
object[] attrs = memInfo[0].GetCustomAttributes(typeof(System.ComponentModel.DescriptionAttribute), false);
if (attrs != null && attrs.Length > 0)
return ((DescriptionAttribute)attrs[0]).Description;
}
return en.ToString();
}
}
}
using Microsoft.Extensions.Configuration;
using Qiniu.Http;
using Qiniu.Storage;
using Qiniu.Util;
using System.IO;
using System.Threading.Tasks;
namespace Common.Helper
{
public class QiNiuCloudUtils
{
private readonly IConfigurationRoot configuration;
private readonly string AccessKey = string.Empty;
public readonly string SecretKey = string.Empty;
public readonly string _cdnUrl = string.Empty;
public QiNiuCloudUtils()
{
configuration = Configurations.Get(DirectoryFinder.CalculateContentRootFolder());
AccessKey = configuration["QiNiu:AccessKey"];
SecretKey = configuration["QiNiu:SecretKey"];
_cdnUrl = configuration["QiNiu:cdnUrl"];
}
public string cdnUrl
{
get
{
return _cdnUrl;
}
}
/// <summary>
/// 刊登cdn地址
/// </summary>
//public static readonly string PublishListingCdnUrl = ConfigManagerConf.GetValue("QiNiu:PublishListingCdnUrl");
/// <summary>
/// 七牛存储节点
/// </summary>
private static readonly string Bucket = "bailun-oms";
#region 上传文件
/// <summary>
/// 上传文件
/// </summary>
/// <param name="saveFile"></param>
/// <param name="content"></param>
/// <returns></returns>
public async Task<HttpResult> UploadStreamAsync(string saveFile, byte[] content)
{
Mac mac = new Mac(AccessKey, SecretKey);
// 设置上传策略,详见:https://developer.qiniu.com/kodo/manual/1206/put-policy
PutPolicy putPolicy = new PutPolicy();
putPolicy.Scope = Bucket + ":" + saveFile; //覆盖式更新
// putPolicy.SetExpires(3600);
string token = Auth.CreateUploadToken(mac, putPolicy.ToJsonString());
Qiniu.Storage.Config config = new Qiniu.Storage.Config();
// 设置上传区域
config.Zone = Zone.ZoneCnSouth;
// 设置 http 或者 https 上传
//config.UseHttps = true;
//config.UseCdnDomains = true;
//config.ChunkSize = ChunkUnit.U512K;
FormUploader target = new FormUploader(config);
var result = await target.UploadStream(new MemoryStream(content), saveFile, token, null);
//result.code==200 上传成功
return result;
}
#endregion
public async Task<HttpResult> UploadBigStreamAsync(string saveFile, string localFile, string mimeType = "")
{
Mac mac = new Mac(AccessKey, SecretKey);
// 设置上传策略,详见:https://developer.qiniu.com/kodo/manual/1206/put-policy
PutPolicy putPolicy = new PutPolicy();
putPolicy.Scope = Bucket + ":" + saveFile; //覆盖式更新
if (!string.IsNullOrEmpty(mimeType))
{
putPolicy.MimeLimit = mimeType;
}
// putPolicy.SetExpires(3600);
string token = Auth.CreateUploadToken(mac, putPolicy.ToJsonString());
Config config = new Config
{
Zone = Zone.ZoneCnSouth,
ChunkSize = ChunkUnit.U1024K
};
// 包含两个参数,并且都有默认值
// 参数1(bool): uploadFromCDN是否从CDN加速上传,默认否
// 参数2(enum): chunkUnit上传分片大小,可选值128KB,256KB,512KB,1024KB,2048KB,4096KB
ResumableUploader ru = new ResumableUploader(config);
UploadProgressHandler upph = new UploadProgressHandler(ResumableUploader.DefaultUploadProgressHandler);
var putExtra = new PutExtra
{
ProgressHandler = upph,
MaxRetryTimes = 10,
};
// ResumableUploader.UploadFile有多种形式,您可以根据需要来选择
//
// 最简模式,使用默认recordFile和默认uploadProgressHandler
// UploadFile(localFile,saveKey,token)
//
// 基本模式,使用默认uploadProgressHandler
// UploadFile(localFile,saveKey,token,recordFile)
//
// 一般模式,使用自定义进度处理(可以监视上传进度)
// UploadFile(localFile,saveKey,token,recordFile,uploadProgressHandler)
//
// 高级模式,包含上传控制(可控制暂停/继续 或者强制终止)
// UploadFile(localFile,saveKey,token,recordFile,uploadProgressHandler,uploadController)
//
// 支持自定义参数
//var extra = new System.Collections.Generic.Dictionary<string, string>();
//extra.Add("FileType", "UploadFromLocal");
//extra.Add("YourKey", "YourValue");
//uploadFile(...,extra,...)
//UploadController upctl = new UploadController();
var result = await ru.UploadFile(localFile, saveFile, token, putExtra);
return result;
}
}
}
using System.Collections.Generic;
using static Domain.TakeStock.TakeStockEnum;
namespace Domain.Dto
{
/// <summary>
/// 审核计划单
/// </summary>
public class AuditTakeStockScheduleInputDto
{
/// <summary>
/// 计划单id
/// </summary>
public List<int> ScheduleIds { get; set; }
/// <summary>
/// 审核人姓名
/// </summary>
public string AuditUserName { get; set; }
/// <summary>
/// 审核人id
/// </summary>
public int AuditUserId { get; set; }
/// <summary>
/// 审核状态
/// </summary>
public TSScheduleState State { get; set; }
/// <summary>
/// 审核说明
/// </summary>
public string AuditExplain { get; set; }
}
}
using System.Collections.Generic;
namespace Domain.Dto
{
/// <summary>
/// 取消计划单
/// </summary>
public class CancelTakeStockScheduleInPutDto
{
/// <summary>
/// 计划单id
/// </summary>
public List<int> ScheduleIds { get; set; }
/// <summary>
/// 修改人姓名
/// </summary>
public string LastModifierUserName { get; set; }
/// <summary>
/// 最后修改人id
/// </summary>
public int LastModifierUserId { get; set; }
}
}
using System;
namespace Domain.Dto
{
/// <summary>
/// 冻结库存请求参数
/// </summary>
public class FreezeStockInputDot
{
/// <summary>
/// 第三方单号
/// </summary>
public string ExternalCode { get; set; }
public string warehouseCode { get; set; }
public string sku { get; set; }
/// <summary>
/// 计划创建时间
/// </summary>
public DateTime CheduleCreationTime { get; set; }
}
}
using System;
namespace Domain.Dto
{
/// <summary>
/// 手动修正sku数量
/// </summary>
public class ModifStockInputDto
{
public string WarehouseCode { get; set; }
public string Sku { get; set; }
public int Quantity { get; set; }
/// <summary>
/// 第三方单号
/// </summary>
public string ExternalCode { get; set; }
/// <summary>
/// 计划单创建时间
/// </summary>
public DateTime CheduleCreationTime { get; set; }
}
}
namespace Domain.Dto
{
public class TakeStockFreezeOutputDto
{
public bool IsFreeze { get; set; }
/// <summary>
///
/// </summary>
public string Sku { get; set; }
public int Quantity { get; set; }
}
}
namespace Domain.Dto
{
public class RequestDto<T>
{
public T Data { get; set; }
}
}
namespace Domain.Dto
{
public class WMSResponseDto<T>
{
/// <summary>
/// 指示是否成功
/// </summary>
public bool IsSuccess { get; set; }
/// <summary>
/// 返回的业务数据
/// </summary>
public T Data { get; set; }
/// <summary>
/// 消息
/// </summary>
public string Message { get; set; }
/// <summary>
/// HTTP状态码
/// </summary>
public int Code { get; set; }
}
}
......@@ -4,8 +4,10 @@ using System.Text;
namespace Domain.TakeStock.Repository
{
public interface ITakeStockScheduleRepository: IRepository<TakeStockSchedule>
public interface ITakeStockScheduleRepository : IRepository<TakeStockSchedule>
{
int CreateOrder(TakeStockSchedule order, List<TakeStockOrder> orders);
int CreateOrderAndFreezeStock(TakeStockSchedule schedule, List<TakeStockOrder> orders);
}
}
......@@ -8,11 +8,13 @@ namespace Domain.TakeStock
{
public enum TSScheduleState
{
创建,
审核,
完成,
取消,
异常
创建 = 0,
待审核 = 1,
完成 = 2,
取消 = 3,
异常 = 4,
盘点中 = 5,
审核不通过 = 6
}
public enum TSOrderState
......
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using static Domain.TakeStock.TakeStockEnum;
......@@ -29,12 +30,12 @@ namespace Domain.TakeStock
/// </summary>
[SugarColumn(Length = 20)]
public string WarehouseCode { get; set; }
/// <summary>
/// 盘点人Id
/// </summary>
public int ExecutorId { get; set; }
/// <summary>
/// 系统自动盘点
/// </summary>
......@@ -77,5 +78,163 @@ namespace Domain.TakeStock
[SugarColumn(IsNullable = true)]
public string LastModifierUserName { get; set; }
/// <summary>
/// 系统交易流水号
/// </summary>
[SugarColumn(IsNullable = true, Length = 45)]
public string SysSerialNumber { get; set; }
/// <summary>
/// 审核人id
/// </summary>
public int? AuditUserId { get; set; }
/// <summary>
/// 审核人姓名
/// </summary>
public string AuditUserName { get; set; }
/// <summary>
/// 审核时间
/// </summary>
public DateTime? AuditDateTime { get; set; }
/// <summary>
/// 审核说明
/// </summary>
public string AuditExplain { get; set; }
/// <summary>
/// 盘点类型
/// </summary>
public TakeStockType TakeStockType { get; set; }
/// <summary>
/// 盘亏类型
/// </summary>
public InventoryLossType? InventoryLossType { get; set; }
/// <summary>
/// 退货类型
/// </summary>
public ReturnGoodsType? ReturnGoodsType { get; set; }
/// <summary>
/// 凭证照片地址
/// </summary>
public string CredentialsImgUrl { get; set; }
/// <summary>
/// 退货单类型
/// </summary>
public ReturnOrderNoType? ReturnOrderNoType { get; set; }
/// <summary>
/// 退货单号
/// </summary>
public string ReturnOrderNo { get; set; }
}
/// <summary>
/// 盘点类型
/// </summary>
public enum TakeStockType
{
/// <summary>
/// 默认
/// </summary>
[Description("默认")]
None = 0,
/// <summary>
/// 盘亏
/// </summary>
[Description("盘亏")]
InventoryLoss = 1,
/// <summary>
/// 盘盈
/// </summary>
[Description("盘盈")]
InventorySurplus = 2,
/// <summary>
/// 退货业务
/// </summary>
[Description("退货业务")]
ReturnGoods = 3
}
/// <summary>
/// 盘亏类型
/// </summary>
public enum InventoryLossType
{
/// <summary>
/// 默认
/// </summary>
[Description("默认")]
None = 0,
/// <summary>
///
/// </summary>
[Description("丢失")]
Lose = 1,
/// <summary>
/// 报损
/// </summary>
[Description("报损")]
FrmLoss = 2,
/// <summary>
/// 违禁品
/// </summary>
[Description("违禁品")]
Contraband = 3
}
/// <summary>
/// 退货类型
/// </summary>
public enum ReturnGoodsType
{
/// <summary>
/// 良品
/// </summary>
[Description("良品")]
GoodProduct = 1,
/// <summary>
/// 不良品
/// </summary>
[Description("不良品")]
Rejects = 2,
/// <summary>
/// 换渠道
/// </summary>
[Description("换渠道")]
ChannelChange = 3
}
/// <summary>
/// 退货单号类型
/// </summary>
public enum ReturnOrderNoType
{
/// <summary>
/// 默认
/// </summary>
[Description("默认")]
None = 0,
[Description("退货单号")]
AllotOrderCode = 1,
/// <summary>
/// OMS配货单号
/// </summary>
[Description("OMS配货单号")]
AcOrderCode = 2,
/// <summary>
/// 采购单号
/// </summary>
[Description("采购单号")]
PurchaseOrderCode = 3,
/// <summary>
/// 其它单号
/// </summary>
[Description("其它单号")]
Other = 4
}
}
using Domain.TakeStock;
using Domain.Dto;
using Domain.TakeStock;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
......@@ -79,5 +80,19 @@ namespace IService.TakeStock
///// <param name="sku"></param>
///// <returns></returns>
//Task<bool> SyncAndEnabledAsync(int id);
/// <summary>
/// 审核计划单
/// </summary>
/// <param name="inputDto"></param>
/// <returns></returns>
Task<ReturnPlanDto> AuditTakeStockSchedule(AuditTakeStockScheduleInputDto inputDto);
/// <summary>
/// 取消盘点计划单
/// </summary>
/// <param name="scheduleIds"></param>
/// <returns></returns>
Task<ReturnPlanDto> CancelTakeStockSchedule(CancelTakeStockScheduleInPutDto input);
}
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Common.Helper;
using Domain.Dto;
using Domain.TakeStock;
using IService.TakeStock;
using Microsoft.AspNetCore.Authorization;
......@@ -51,13 +54,13 @@ namespace TakeStock.API.Controllers
var result = await takeStockAppService.CreateTakeStockSchedule(record);
return result;
}
[HttpPost("StartTakeStock")]
public async Task<bool> StartTakeStock([FromBody] StartTakeStockInputDto input)
{
return await takeStockAppService.StartTakeStock(input);
}
[HttpPost("CanceledInform")]
public async Task<bool> CanceledInform([FromBody] CanceledInformInputDto input)
{
......@@ -117,5 +120,45 @@ namespace TakeStock.API.Controllers
{
return await takeStockAppService.SearchOrderLogs(id);
}
/// <summary>
/// 上传照片凭据
/// </summary>
/// <param name="file"></param>
/// <returns></returns>
[HttpPost("UploadCredentials")]
public async Task<string> UploadCredentials(IFormFile file)
{
var fileExtension = Path.GetExtension(file.FileName);
var stream = file.OpenReadStream();
byte[] bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length);
stream.Seek(0, SeekOrigin.Begin);
string fileName = Guid.NewGuid().ToString("N") + fileExtension;
var result = await new QiNiuCloudUtils().UploadStreamAsync(fileName, bytes);
return result.Code == 200 ? $"http://omsimg.blsct.com/{fileName}" : string.Empty;
}
/// <summary>
/// 审核计划单
/// </summary>
/// <param name="inputDto"></param>
/// <returns></returns>
[HttpPost("AuditTakeStockSchedule")]
public async Task<ReturnPlanDto> AuditTakeStockSchedule([FromBody] AuditTakeStockScheduleInputDto inputDto)
{
return await takeStockAppService.AuditTakeStockSchedule(inputDto);
}
/// <summary>
/// 取消盘点计划单
/// </summary>
/// <param name="scheduleIds"></param>
/// <returns></returns>
[HttpPost("CancelTakeStockSchedule")]
public async Task<ReturnPlanDto> CancelTakeStockSchedule(CancelTakeStockScheduleInPutDto input)
{
return await takeStockAppService.CancelTakeStockSchedule(input);
}
}
}
......@@ -17,5 +17,10 @@
},
"App": {
"CorsOrigins": "*"
}, //ţ
"QiNiu": {
"AccessKey": "QSvtvN4Ons1CiNzaMGqx8XmDaiM1L0ZqSwJ2YoTn",
"SecretKey": "yagRd-cBOVhkRGGT-o_reMqNVjI8_k7YwoTXkhrm",
"CdnUrl": "http://omsimg.blsct.com/"
}
}
......@@ -17,5 +17,11 @@
},
"App": {
"CorsOrigins": "*"
}
},
//ţ
"QiNiu": {
"AccessKey": "QSvtvN4Ons1CiNzaMGqx8XmDaiM1L0ZqSwJ2YoTn",
"SecretKey": "yagRd-cBOVhkRGGT-o_reMqNVjI8_k7YwoTXkhrm",
"CdnUrl": "http://omsimg.blsct.com/"
}
}
\ No newline at end of file
......@@ -17,6 +17,11 @@ namespace TakeStock.Application.TakeStock.Dto
/// </summary>
public string Sku { get; set; }
public long? CreatorUserId { get; set; }
public long? CreatorUserId { get; set; }
/// <summary>
/// 盘点后数量 - 手动盘点时生效
/// </summary>
public int? AfterQuantity { get; set; }
}
}
using System;
using Domain.TakeStock;
using System;
using System.Collections.Generic;
using System.Text;
using static Domain.TakeStock.TakeStockEnum;
......@@ -35,5 +36,34 @@ namespace TakeStock.Application.TakeStock.Dto
public string CreatorUserName { get; set; }
public virtual List<OrderInputDto> Orders { get; set; }
/// <summary>
/// 盘点类型
/// </summary>
public TakeStockType TakeStockType { get; set; }
/// <summary>
/// 盘亏类型
/// </summary>
public InventoryLossType? InventoryLossType { get; set; }
/// <summary>
/// 退货类型
/// </summary>
public ReturnGoodsType? ReturnGoodsType { get; set; }
/// <summary>
/// 凭证照片地址
/// </summary>
public string CredentialsImgUrl { get; set; }
/// <summary>
/// 退货单类型
/// </summary>
public ReturnOrderNoType? ReturnOrderNoType { get; set; }
/// <summary>
/// 退货单号
/// </summary>
public string ReturnOrderNo { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Text;
using static Domain.TakeStock.TakeStockEnum;
using Common.Extensions;
using Domain.TakeStock;
using System;
namespace TakeStock.Application.TakeStock.Dto
{
......@@ -56,5 +55,67 @@ namespace TakeStock.Application.TakeStock.Dto
public long? DeleterUserId { get; set; }
public DateTime? DeletionTime { get; set; }
/// <summary>
/// 系统交易流水号
/// </summary>
public string SysSerialNumber { get; set; }
/// <summary>
/// 审核人id
/// </summary>
public int? AuditUserId { get; set; }
/// <summary>
/// 审核人姓名
/// </summary>
public string AuditUserName { get; set; }
/// <summary>
/// 审核时间
/// </summary>
public DateTime? AuditDateTime { get; set; }
/// <summary>
/// 审核时间
/// </summary>
public string AuditDateTimeStr => AuditDateTime.HasValue ? AuditDateTime.Value.ToLongStr() : string.Empty;
/// <summary>
/// 审核说明
/// </summary>
public string AuditExplain { get; set; }
/// <summary>
/// 盘点类型
/// </summary>
public TakeStockType TakeStockType { get; set; }
/// <summary>
/// 盘点类型
/// </summary>
public string TakeStockTypeStr => TakeStockType.GetEnumDes();
/// <summary>
/// 凭证照片地址
/// </summary>
public string CredentialsImgUrl { get; set; }
/// <summary>
/// 盘亏类型
/// </summary>
public InventoryLossType? InventoryLossType { get; set; }
public string InventoryLossTypeStr => InventoryLossType.HasValue ? InventoryLossType.Value.GetEnumDes() : string.Empty;
/// <summary>
/// 退货单类型
/// </summary>
public ReturnOrderNoType? ReturnOrderNoType { get; set; }
public string ReturnOrderNoTypeStr => ReturnOrderNoType.HasValue ? ReturnOrderNoType.Value.GetEnumDes() : string.Empty;
/// <summary>
/// 退货单号
/// </summary>
public string ReturnOrderNo { get; set; }
}
}
using AutoMapper;
using Common.Extensions;
using Domain.Dto;
using Domain.TakeStock;
using IService.TakeStock;
using Newtonsoft.Json;
......@@ -29,6 +30,15 @@ namespace TakeStock.Application.TakeStock
var str = JsonConvert.SerializeObject(input);
TakeStockSchedule schedule = JsonConvert.DeserializeObject<TakeStockSchedule>(str);
List<TakeStockOrder> orders = JObject.Parse(str)["Orders"].ToObject<List<TakeStockOrder>>();
schedule.State = TakeStockEnum.TSScheduleState.待审核;
if (input.IsAutomation) // 自动盘点
{
orders.ForEach(x => x.AfterQuantity = null);
}
else if(orders.Count(x => !x.AfterQuantity.HasValue)>0)
{
return new ReturnPlanDto { Message = "手动盘点sku的实际数量不能为空!" };
}
return await takeStockService.CreateTakeStockOrderAsync(schedule, orders);
}
......@@ -186,5 +196,25 @@ namespace TakeStock.Application.TakeStock
{
//await takeStockService.PushTakeStockMsg(100);
}
/// <summary>
/// 审核计划单
/// </summary>
/// <param name="inputDto"></param>
/// <returns></returns>
public async Task<ReturnPlanDto> AuditTakeStockSchedule(AuditTakeStockScheduleInputDto inputDto)
{
return await takeStockService.AuditTakeStockSchedule(inputDto);
}
/// <summary>
/// 取消盘点计划单
/// </summary>
/// <param name="scheduleIds"></param>
/// <returns></returns>
public async Task<ReturnPlanDto> CancelTakeStockSchedule(CancelTakeStockScheduleInPutDto input)
{
return await takeStockService.CancelTakeStockSchedule(input);
}
}
}
......@@ -3,6 +3,7 @@ using Domain.TakeStock.Repository;
using SqlSugar;
using System;
using System.Collections.Generic;
using static Domain.TakeStock.TakeStockEnum;
namespace TakeStock.SqlSugar.Repository.TakeStock
{
......@@ -22,7 +23,8 @@ namespace TakeStock.SqlSugar.Repository.TakeStock
{
var order = orders[i];
order.ScheduleId = scheduleId;
order = client.Insertable(order).ExecuteReturnEntity();
order = client.Insertable(order).ExecuteReturnEntity();
}
client.Ado.CommitTran();
return scheduleId;
......@@ -33,5 +35,29 @@ namespace TakeStock.SqlSugar.Repository.TakeStock
return 0;
}
}
public int CreateOrderAndFreezeStock(TakeStockSchedule schedule, List<TakeStockOrder> orders)
{
try
{
client.Ado.BeginTran();
int scheduleId = InsertAndGetId(schedule);
for (int i = 0; i < orders.Count; i++)
{
var order = orders[i];
order.ScheduleId = scheduleId;
order = client.Insertable(order).ExecuteReturnEntity();
var log = new TakeStockOrderLog { OrderId = order.Id, State = TSOrderState.冻结库存, Content = "冻结库存成功。" , CreationTime =DateTime.Now};
client.Insertable(log);
}
client.Ado.CommitTran();
return scheduleId;
}
catch (Exception ex)
{
client.Ado.RollbackTran();
return 0;
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment