提交盘点信息
This commit is contained in:
@ -44,6 +44,8 @@ namespace WCS.BLL.Services.IService
|
||||
public Task<ResponseCommon<object>> updateStocktakingInfo(UpdateStocktakingInfoRequest request);
|
||||
|
||||
public Task<ResponseCommon<object>> deleteStocktakingInfos(DeleteInfosRequest request);
|
||||
|
||||
public Task<ResponseCommon<object>> commitStocktakingInfos(DeleteInfosRequest request);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,4 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WCS.BLL.Config;
|
||||
using WCS.BLL.Config;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.Manager;
|
||||
using WCS.BLL.Services.IService;
|
||||
@ -13,7 +7,6 @@ using WCS.DAL.DbModels;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel.InOutRecord;
|
||||
using WCS.Model.ApiModel.MatBaseInfo;
|
||||
using WCS.Model.ApiModel.MatDetailCurrentInfo;
|
||||
using WCS.Model.ApiModel.Stocktaking;
|
||||
using WCS.Model.WebSocketModel;
|
||||
|
||||
@ -1260,6 +1253,87 @@ namespace WCS.BLL.Services.Service
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ResponseCommon<object>> commitStocktakingInfos(DeleteInfosRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
//先查询出具体的Id
|
||||
var stocktakingInfos = await DbHelp.db.Queryable<MatDetailStocktakingInfo>()
|
||||
.Where(t => request.needDeleteIds.Contains(t.Id))
|
||||
.ToListAsync();
|
||||
if (stocktakingInfos == null || stocktakingInfos.Count < request.needDeleteIds.Count)
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"操作失败:请刷新后重试!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
|
||||
if (stocktakingInfos.Where(t => t.StocktakingStatus == StocktakingStatusEnum.已提交).Any())
|
||||
{
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"操作失败:存在已提交的盘点数据!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
|
||||
var marCurrentInfoIds = stocktakingInfos.Select(t => t.MatDetailCurrentId)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
var matCurrentInfos = await DbHelp.db.Queryable<MatDetailCurrentInfo>()
|
||||
.Where(t => marCurrentInfoIds.Contains(t.Id))
|
||||
.ToListAsync();
|
||||
DbHelp.db.BeginTran();
|
||||
foreach (var matCurrentInfo in matCurrentInfos)
|
||||
{
|
||||
var stocktakingInfo = stocktakingInfos.Where(t => t.MatDetailCurrentId == matCurrentInfo.Id)
|
||||
.FirstOrDefault();
|
||||
if (stocktakingInfo == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (stocktakingInfo.StocktakingQty != 0)
|
||||
{
|
||||
//TO DO 形成数据更新记录
|
||||
matCurrentInfo.MatQty = stocktakingInfo.StocktakingQty;
|
||||
matCurrentInfo.ModifyUser = request.UserName;
|
||||
matCurrentInfo.ModifyTime = DateTime.Now;
|
||||
|
||||
DbHelp.db.Updateable(matCurrentInfo).ExecuteCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
//TO DO 形成数据更新记录
|
||||
|
||||
DbHelp.db.Deleteable(matCurrentInfo).ExecuteCommand();
|
||||
}
|
||||
stocktakingInfo.StocktakingStatus = StocktakingStatusEnum.已提交;
|
||||
DbHelp.db.Updateable(stocktakingInfo).ExecuteCommand();
|
||||
}
|
||||
DbHelp.db.CommitTran();
|
||||
return new ResponseCommon<object>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = "success",
|
||||
Data = null,
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var response = new ResponseCommon<Object>
|
||||
{
|
||||
Code = 300,
|
||||
Message = $"操作失败:{ex.Message}",
|
||||
Data = null
|
||||
};
|
||||
return response;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -101,5 +101,20 @@ namespace WCS.WebApi.Controllers
|
||||
}
|
||||
return await _stockTakingService.deleteStocktakingInfos(request);
|
||||
}
|
||||
|
||||
[HttpPost("commitStocktakingInfos")]
|
||||
public async Task<ResponseCommon<object>> commitStocktakingInfos(DeleteInfosRequest request)
|
||||
{
|
||||
//校验
|
||||
if (request.needDeleteIds == null || request.needDeleteIds.Count == 0)
|
||||
{
|
||||
return new ResponseCommon<object>()
|
||||
{
|
||||
Code = 201,
|
||||
Message = "操作失败:参数校验失败(ID)."
|
||||
};
|
||||
}
|
||||
return await _stockTakingService.commitStocktakingInfos(request);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,31 +1,16 @@
|
||||
using HandyControl.Controls;
|
||||
using MiniExcelLibs;
|
||||
using Ping9719.WpfEx.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using SqlSugar;
|
||||
using HandyControl.Data;
|
||||
using System.Windows;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using 智慧物流软件系统.Views.Controls;
|
||||
using WCS.Model.ApiModel.User;
|
||||
using 智慧物流软件系统.Api;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel;
|
||||
using System.Windows.Controls;
|
||||
using WCS.Model.ApiModel.InterfaceRecord;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.Model.ApiModel.MatBaseInfo;
|
||||
using System.Collections.ObjectModel;
|
||||
using HandyControl.Tools.Extension;
|
||||
using 智慧物流软件系统.Tool;
|
||||
using WCS.Model.ApiModel.Stocktaking;
|
||||
|
||||
namespace 智慧物流软件系统.ViewModel
|
||||
@ -45,7 +30,7 @@ namespace 智慧物流软件系统.ViewModel
|
||||
StocktakingStatuses.Add(status.ToString());
|
||||
}
|
||||
|
||||
selectedStocktakingStatus = StocktakingStatuses.First();
|
||||
SelectedStocktakingStatus = StocktakingStatuses.First();
|
||||
}
|
||||
|
||||
#region Property
|
||||
@ -140,7 +125,7 @@ namespace 智慧物流软件系统.ViewModel
|
||||
MatCode = string.Empty;
|
||||
MatName = string.Empty;
|
||||
StocktakingUser = string.Empty;
|
||||
|
||||
SelectedStocktakingStatus = StocktakingStatuses.First();
|
||||
}
|
||||
|
||||
public ICommand BtnSearchCommand { get => new DelegateCommand(BtnSearchReset); }
|
||||
@ -193,6 +178,48 @@ namespace 智慧物流软件系统.ViewModel
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 物料删除操作
|
||||
/// </summary>
|
||||
public ICommand BtnCommitCommand { get => new DelegateCommand(BtnCommit); }
|
||||
public async void BtnCommit()
|
||||
{
|
||||
Growl.Ask($"是否提交所有勾选得数据]!", isConfirmed =>
|
||||
{
|
||||
if (isConfirmed)
|
||||
{
|
||||
//查询勾选的第一个数据
|
||||
var needDeleteIds = DataGridItemSource?.Where(t => t.IsSelected == true)
|
||||
.Select(t => t.Id)
|
||||
.ToList();
|
||||
if (needDeleteIds == null)
|
||||
{
|
||||
Growl.Warning("请选择需要提交的数据!");
|
||||
}
|
||||
else
|
||||
{
|
||||
var body = new DeleteInfosRequest()
|
||||
{
|
||||
UserName = LocalStatic.CurrentUser,
|
||||
DeviceType = LocalFile.Config.DeviceType,
|
||||
needDeleteIds = needDeleteIds,
|
||||
};
|
||||
var Result = ApiHelp.GetDataFromHttp<ResponseBase<UserModel>>(LocalFile.Config.ApiIpHost + "PDAStocktaking/commitStocktakingInfos", body, "POST");
|
||||
if (Result != null && Result.Code == 200)
|
||||
{
|
||||
CurrentPage = 1;
|
||||
Growl.Success("提交成功!" + Result?.Message);
|
||||
}
|
||||
else
|
||||
{
|
||||
Growl.Error($"{Result?.Message?.ToString()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 物料修改操作
|
||||
/// </summary>
|
||||
|
@ -120,7 +120,7 @@
|
||||
FontFamily="{StaticResource IconFont}"
|
||||
Foreground="WhiteSmoke"
|
||||
Background="HotPink"
|
||||
Command="{Binding BtnAddCommand}"></Button>
|
||||
Command="{Binding BtnCommitCommand}"></Button>
|
||||
<Button MinHeight="40"
|
||||
FontSize="18"
|
||||
Margin="5"
|
||||
|
Reference in New Issue
Block a user