|
@@ -1,19 +1,14 @@
|
|
|
using Aspose.Cells;
|
|
|
using AutoMapper;
|
|
|
using EyeSoft.Collections.Generic;
|
|
|
-using EyeSoft.Runtime.InteropServices;
|
|
|
using Newtonsoft.Json;
|
|
|
-using Npgsql.Replication.PgOutput.Messages;
|
|
|
using OASystem.Domain;
|
|
|
using OASystem.Domain.Dtos.PersonnelModule;
|
|
|
-using OASystem.Domain.Dtos.System;
|
|
|
using OASystem.Domain.Entities.Groups;
|
|
|
using OASystem.Domain.Entities.PersonnelModule;
|
|
|
using OASystem.Domain.ViewModels.PersonnelModule;
|
|
|
using OASystem.Infrastructure.Repositories.System;
|
|
|
using OASystem.Infrastructure.Tools;
|
|
|
-using System.Linq;
|
|
|
-using System.Text.RegularExpressions;
|
|
|
|
|
|
namespace OASystem.Infrastructure.Repositories.PersonnelModule
|
|
|
{
|
|
@@ -114,7 +109,7 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
|
|
|
};
|
|
|
|
|
|
_jv.Code = StatusCodes.Status200OK;
|
|
|
- _jv.Data = new { goodsTypeData = typeData, stockStatus = stockStatus, receiveStatus = receiveStatus, groupNameData = groupData, userNameData = userData };
|
|
|
+ _jv.Data = new { goodsTypeData = typeData, stockStatus, receiveStatus, groupNameData = groupData, userNameData = userData };
|
|
|
_jv.Msg = $"操作成功";
|
|
|
return _jv;
|
|
|
}
|
|
@@ -428,11 +423,13 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
|
|
|
.OrderByDescending(gs => gs.CreateTime)
|
|
|
.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
|
|
|
|
|
|
-
|
|
|
+
|
|
|
foreach (var item in data)
|
|
|
{
|
|
|
- var auditDeps = new List<GoodsStorageAuditPerView>();
|
|
|
- auditDeps.Add(new() { AuditPer = hrAuditPer, AuditDep = GoodsAuditDepEnum.Hr, ButtonText = GoodsAuditDepEnum.Hr.GetEnumDescription() });
|
|
|
+ var auditDeps = new List<GoodsStorageAuditPerView>
|
|
|
+ {
|
|
|
+ new() { AuditPer = hrAuditPer, AuditDep = GoodsAuditDepEnum.Hr, ButtonText = GoodsAuditDepEnum.Hr.GetEnumDescription() }
|
|
|
+ };
|
|
|
var auditPer = GoodsAuditType(item.GoodsType);
|
|
|
if (auditPer)
|
|
|
{
|
|
@@ -603,10 +600,11 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
|
|
|
/// <returns></returns>
|
|
|
public List<Pm_GoodsAudit> GoodsStorageConfirm(int auditType, int dataId, int currUserId)
|
|
|
{
|
|
|
- var goodsAuditList = new List<Pm_GoodsAudit>();
|
|
|
-
|
|
|
- goodsAuditList.Add(new Pm_GoodsAudit(auditType, GoodsAuditDepEnum.Hr, dataId, GoodsConfirmEnum.WaitConfirm, currUserId));
|
|
|
- goodsAuditList.Add(new Pm_GoodsAudit(auditType, GoodsAuditDepEnum.Financial, dataId, GoodsConfirmEnum.WaitConfirm, currUserId));
|
|
|
+ var goodsAuditList = new List<Pm_GoodsAudit>
|
|
|
+ {
|
|
|
+ new(auditType, GoodsAuditDepEnum.Hr, dataId, GoodsConfirmEnum.WaitConfirm, currUserId),
|
|
|
+ new(auditType, GoodsAuditDepEnum.Financial, dataId, GoodsConfirmEnum.WaitConfirm, currUserId)
|
|
|
+ };
|
|
|
|
|
|
return goodsAuditList;
|
|
|
}
|
|
@@ -719,7 +717,7 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
|
|
|
{
|
|
|
confirmStatus = GoodsConfirmEnum.Confirmed;
|
|
|
}
|
|
|
- else if (preInfos.Where(x => x.AuditStatus == GoodsConfirmEnum.Confirmed).Count() >= 1)
|
|
|
+ else if (preInfos.Count(x => x.AuditStatus == GoodsConfirmEnum.Confirmed) >= 1)
|
|
|
{
|
|
|
confirmStatus = GoodsConfirmEnum.PartConfirmed;
|
|
|
}
|
|
@@ -831,7 +829,7 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
|
|
|
/// 2:出库审核
|
|
|
/// </param>
|
|
|
/// <returns></returns>
|
|
|
- public (bool, GoodsAuditDepEnum) GoodsAuditDep(int userId, GoodsAuditDepEnum auditDepEnum, int auditType = 1)
|
|
|
+ public static (bool, GoodsAuditDepEnum) GoodsAuditDep(int userId, GoodsAuditDepEnum auditDepEnum, int auditType = 1)
|
|
|
{
|
|
|
if (userId < 1) return (false, GoodsAuditDepEnum.Hr);
|
|
|
|
|
@@ -857,7 +855,7 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
|
|
|
/// 2:出库审核
|
|
|
/// </param>
|
|
|
/// <returns></returns>
|
|
|
- public List<GoodsAuditDepView> GoodsStorageConfirmAuditDep(int auditType = 1)
|
|
|
+ public static List<GoodsAuditDepView> GoodsStorageConfirmAuditDep(int auditType = 1)
|
|
|
{
|
|
|
var auditList = new List<GoodsAuditDepView>();
|
|
|
|
|
@@ -945,9 +943,9 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
|
|
|
}
|
|
|
|
|
|
var goodsInfo = await _sqlSugar.Queryable<Pm_GoodsInfo>().FirstAsync(x => x.Id == goodsId);
|
|
|
- goodsInfo.SQ_Total = goodsInfo.SQ_Total - delAgoQuantity;
|
|
|
- goodsInfo.StockQuantity = goodsInfo.StockQuantity - delAgoQuantity;
|
|
|
- goodsInfo.PriceTotal = goodsInfo.PriceTotal - delAgoTotalPrice;
|
|
|
+ goodsInfo.SQ_Total -= delAgoQuantity;
|
|
|
+ goodsInfo.StockQuantity -= delAgoQuantity;
|
|
|
+ goodsInfo.PriceTotal -= delAgoTotalPrice;
|
|
|
goodsInfo.LastUpdateUserId = userId;
|
|
|
goodsInfo.LastUpdateTime = DateTime.Now;
|
|
|
|
|
@@ -1059,8 +1057,10 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
|
|
|
}
|
|
|
|
|
|
//载入模板
|
|
|
- WorkbookDesigner designer = new WorkbookDesigner();
|
|
|
- designer.Workbook = new Workbook(excelTempPath);
|
|
|
+ WorkbookDesigner designer = new()
|
|
|
+ {
|
|
|
+ Workbook = new Workbook(excelTempPath)
|
|
|
+ };
|
|
|
|
|
|
designer.SetDataSource("Export", data);
|
|
|
|
|
@@ -1304,8 +1304,10 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
|
|
|
}
|
|
|
|
|
|
//载入模板
|
|
|
- WorkbookDesigner designer = new WorkbookDesigner();
|
|
|
- designer.Workbook = new Workbook(excelTempPath);
|
|
|
+ WorkbookDesigner designer = new()
|
|
|
+ {
|
|
|
+ Workbook = new Workbook(excelTempPath)
|
|
|
+ };
|
|
|
|
|
|
var tableData = await data.ToListAsync();
|
|
|
foreach (var item in tableData)
|
|
@@ -1325,9 +1327,10 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
|
|
|
var oldAuditDatas = await _sqlSugar.Queryable<Pm_GoodsAudit>()
|
|
|
.LeftJoin<Sys_Users>((x, u) => x.AuditUserId == u.Id)
|
|
|
.Where((x, u) => x.IsDel == 0 && x.Type == 2 && x.DataId == item.Id)
|
|
|
- .Select((x, u) => new {
|
|
|
- x.AuditTime,
|
|
|
- u.CnName
|
|
|
+ .Select((x, u) => new
|
|
|
+ {
|
|
|
+ x.AuditTime,
|
|
|
+ u.CnName
|
|
|
})
|
|
|
.ToListAsync();
|
|
|
if (oldAuditDatas.Any())
|
|
@@ -1340,11 +1343,12 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
|
|
|
else item.AuditTime = DateTime.Now;
|
|
|
}
|
|
|
else
|
|
|
- {
|
|
|
+ {
|
|
|
var newAuditDatas = await _sqlSugar.Queryable<Sys_AuditRecord>()
|
|
|
- .InnerJoin<Sys_AuditFlow>((x,y) => x.FlowId == y.Id)
|
|
|
+ .InnerJoin<Sys_AuditFlow>((x, y) => x.FlowId == y.Id)
|
|
|
.Where((x, y) => x.IsDel == 0 && y.BusinessType == 1 && y.BusinessId == item.Id)
|
|
|
- .Select((x, y) => new {
|
|
|
+ .Select((x, y) => new
|
|
|
+ {
|
|
|
x.AuditTime,
|
|
|
x.AuditorName
|
|
|
})
|
|
@@ -1396,7 +1400,8 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
|
|
|
var oldAuditDatas = await _sqlSugar.Queryable<Pm_GoodsAudit>()
|
|
|
.LeftJoin<Sys_Users>((x, u) => x.AuditUserId == u.Id)
|
|
|
.Where((x, u) => x.IsDel == 0 && x.Type == 2 && x.DataId == item.Id)
|
|
|
- .Select((x, u) => new {
|
|
|
+ .Select((x, u) => new
|
|
|
+ {
|
|
|
x.AuditTime,
|
|
|
u.CnName
|
|
|
})
|
|
@@ -1415,7 +1420,8 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
|
|
|
var newAuditDatas = await _sqlSugar.Queryable<Sys_AuditRecord>()
|
|
|
.InnerJoin<Sys_AuditFlow>((x, y) => x.FlowId == y.Id)
|
|
|
.Where((x, y) => x.IsDel == 0 && y.BusinessType == 1 && y.BusinessId == item.Id)
|
|
|
- .Select((x, y) => new {
|
|
|
+ .Select((x, y) => new
|
|
|
+ {
|
|
|
x.AuditTime,
|
|
|
x.AuditorName
|
|
|
})
|
|
@@ -1514,8 +1520,8 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
|
|
|
{
|
|
|
subData.Add(new
|
|
|
{
|
|
|
- StorageId = item.StorageId,
|
|
|
- BatchNo = storageInfo.BatchNo,
|
|
|
+ item.StorageId,
|
|
|
+ storageInfo.BatchNo,
|
|
|
RecsiveQuantity = item.Quantity
|
|
|
});
|
|
|
goodsStorageInfoStr += $"物品名称:{data.GoodsName} 批次号:{storageInfo.BatchNo} 领用数量:{item.Quantity} \r\n";
|
|
@@ -1583,9 +1589,9 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
|
|
|
var goodsAuditInfo1 = new Pm_GoodsAudit(2, GoodsAuditDepEnum.Hr_Reception, info.Id, GoodsConfirmEnum.WaitConfirm, currUserId);
|
|
|
var goodsAuditInfo2 = new Pm_GoodsAudit(2, GoodsAuditDepEnum.Hr, info.Id, GoodsConfirmEnum.WaitConfirm, currUserId);
|
|
|
var goodsAuditInfos = new List<Pm_GoodsAudit>() { goodsAuditInfo1 };
|
|
|
-
|
|
|
+
|
|
|
//状态描述
|
|
|
- StringBuilder stringBuilder = new StringBuilder();
|
|
|
+ StringBuilder stringBuilder = new();
|
|
|
stringBuilder.Append($"领用确认:状态:待确认 审核人:- 审核时间:-;<br/>");
|
|
|
|
|
|
if (isAuditPer)
|
|
@@ -1676,7 +1682,7 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
|
|
|
{
|
|
|
if (idArray.Length < 1) return _jv;
|
|
|
|
|
|
- if (!Enum.IsDefined(typeof(GoodsAuditEnum),(int)auditEnum))
|
|
|
+ if (!Enum.IsDefined(typeof(GoodsAuditEnum), (int)auditEnum))
|
|
|
{
|
|
|
_jv.Msg = $"出库确认状态超出可用范围!";
|
|
|
return _jv;
|
|
@@ -1763,8 +1769,8 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
|
|
|
else //单人审核
|
|
|
{
|
|
|
//领用确认 --> 已确认 / 领用拒绝 --> 已拒绝
|
|
|
- _jv = await GoodsReceiveOutConfirmingSingle(receiveInfo,userId, currUserName,auditEnum);
|
|
|
-
|
|
|
+ _jv = await GoodsReceiveOutConfirmingSingle(receiveInfo, userId, currUserName, auditEnum);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
if (_jv.Code == StatusCodes.Status200OK)
|
|
@@ -1988,7 +1994,7 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
|
|
|
}
|
|
|
|
|
|
//处理状态描述
|
|
|
- StringBuilder statusDesc = new StringBuilder();
|
|
|
+ StringBuilder statusDesc = new();
|
|
|
|
|
|
var receiveUserName = _sqlSugar.Queryable<Sys_Users>().First(x => x.Id == receiveInfo.AuditUserId)?.CnName ?? "-";
|
|
|
string receiveStatusDesc = string.Format("{0}:状态:{1} 审核人:{2} 审核时间:{3};<br/>",
|
|
@@ -2192,7 +2198,7 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
|
|
|
}
|
|
|
|
|
|
//处理状态描述
|
|
|
- StringBuilder statusDesc = new StringBuilder();
|
|
|
+ StringBuilder statusDesc = new();
|
|
|
|
|
|
var receiveUserName = _sqlSugar.Queryable<Sys_Users>().First(x => x.Id == receiveInfo.AuditUserId)?.CnName ?? "-";
|
|
|
string receiveStatusDesc = string.Format("{0}:状态:{1} 审核人:{2} 审核时间:{3};<br/>",
|
|
@@ -2338,7 +2344,7 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
|
|
|
if (newStorageInfo == null) continue;
|
|
|
|
|
|
var newEdit = await _sqlSugar.Updateable(newStorageInfo)
|
|
|
- .ReSetValue(x => x.ReceiveQuantity = x.ReceiveQuantity - item.Quantity)
|
|
|
+ .ReSetValue(x => x.ReceiveQuantity -= item.Quantity)
|
|
|
.ExecuteCommandAsync();
|
|
|
|
|
|
if (newEdit < 1)
|
|
@@ -2408,8 +2414,10 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
|
|
|
|
|
|
if (auditInfo == null)
|
|
|
{
|
|
|
- auditInfo = new Pm_GoodsAudit(2, depEnum, receiveInfo.Id, auditStatus, userId);
|
|
|
- auditInfo.AuditUserId = userId;
|
|
|
+ auditInfo = new Pm_GoodsAudit(2, depEnum, receiveInfo.Id, auditStatus, userId)
|
|
|
+ {
|
|
|
+ AuditUserId = userId
|
|
|
+ };
|
|
|
var addStatus = await _sqlSugar.Insertable(auditInfo).ExecuteCommandAsync();
|
|
|
if (addStatus < 1)
|
|
|
{
|
|
@@ -2446,7 +2454,7 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
|
|
|
}
|
|
|
auditInfos = auditInfos.OrderBy(x => x.Dep).ToList();
|
|
|
//处理状态描述
|
|
|
- StringBuilder statusDesc = new StringBuilder();
|
|
|
+ StringBuilder statusDesc = new();
|
|
|
foreach (var auditInf in auditInfos)
|
|
|
{
|
|
|
string auditType = auditInf.Dep == GoodsAuditDepEnum.Hr ? "人事部" : "领用确认";
|
|
@@ -2622,7 +2630,8 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
|
|
|
//回滚库存
|
|
|
var changeGoods = await _sqlSugar
|
|
|
.Updateable(goodsInfo)
|
|
|
- .ReSetValue(it => {
|
|
|
+ .ReSetValue(it =>
|
|
|
+ {
|
|
|
it.StockQuantity += receiveInfo.Quantity;
|
|
|
it.OQ_Total -= receiveInfo.Quantity;
|
|
|
it.LastUpdateTime = DateTime.Now;
|
|
@@ -2653,7 +2662,7 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
|
|
|
if (newStorageInfo == null) continue;
|
|
|
|
|
|
var newEdit = await _sqlSugar.Updateable(newStorageInfo)
|
|
|
- .ReSetValue(x => x.ReceiveQuantity = x.ReceiveQuantity - item.Quantity)
|
|
|
+ .ReSetValue(x => x.ReceiveQuantity -= item.Quantity)
|
|
|
.ExecuteCommandAsync();
|
|
|
|
|
|
if (newEdit < 1)
|
|
@@ -2680,7 +2689,7 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
|
|
|
/// <param name="currUserName"></param>
|
|
|
/// <param name="auditEnum"></param>
|
|
|
/// <returns></returns>
|
|
|
- public async Task<JsonView> GoodsReceiveOutConfirmingSingle(Pm_GoodsReceive receiveInfo, int userId,string currUserName,GoodsAuditEnum auditEnum)
|
|
|
+ public async Task<JsonView> GoodsReceiveOutConfirmingSingle(Pm_GoodsReceive receiveInfo, int userId, string currUserName, GoodsAuditEnum auditEnum)
|
|
|
{
|
|
|
_jv.Code = StatusCodes.Status400BadRequest;
|
|
|
|
|
@@ -2751,9 +2760,9 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
|
|
|
}
|
|
|
|
|
|
//处理状态描述
|
|
|
- StringBuilder statusDesc = new StringBuilder();
|
|
|
+ StringBuilder statusDesc = new();
|
|
|
statusDesc.Append(string.Format("领用确认:状态:{0} 审核人:{1} 审核时间:{2};", auditInfo.AuditStatus.GetEnumDescription(), currUserName, currUserOpTime));
|
|
|
-
|
|
|
+
|
|
|
//批次库存信息
|
|
|
string goodsStorageInfo = receiveInfo.GoodsStorageInfo;
|
|
|
|
|
@@ -2855,7 +2864,8 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
|
|
|
|
|
|
var changeGoods = await _sqlSugar
|
|
|
.Updateable(goodsInfo)
|
|
|
- .ReSetValue(it => {
|
|
|
+ .ReSetValue(it =>
|
|
|
+ {
|
|
|
it.StockQuantity += receiveInfo.Quantity;
|
|
|
it.OQ_Total -= receiveInfo.Quantity;
|
|
|
it.LastUpdateTime = DateTime.Now;
|
|
@@ -2884,7 +2894,7 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
|
|
|
if (newStorageInfo == null) continue;
|
|
|
|
|
|
var newEdit = await _sqlSugar.Updateable(newStorageInfo)
|
|
|
- .ReSetValue(x => x.ReceiveQuantity = x.ReceiveQuantity - item.Quantity)
|
|
|
+ .ReSetValue(x => x.ReceiveQuantity -= item.Quantity)
|
|
|
.ExecuteCommandAsync();
|
|
|
|
|
|
if (newEdit < 1)
|
|
@@ -3072,7 +3082,7 @@ FROM
|
|
|
foreach (var item in view)
|
|
|
{
|
|
|
var details = $"暂无物品信息数据";
|
|
|
-
|
|
|
+
|
|
|
//设置领用详情
|
|
|
if (item.GoodsTypeId < 1)
|
|
|
{
|
|
@@ -3110,10 +3120,11 @@ FROM
|
|
|
|
|
|
//设置领用状态描述
|
|
|
var auditRecords = await _sqlSugar.Queryable<Sys_AuditRecord>()
|
|
|
- .InnerJoin<Sys_AuditFlow>((ar,af) => ar.FlowId == af.Id)
|
|
|
+ .InnerJoin<Sys_AuditFlow>((ar, af) => ar.FlowId == af.Id)
|
|
|
.Where((ar, af) => ar.IsDel == 0 && af.BusinessId == item.Id && af.BusinessType == 1)
|
|
|
- .Select((ar, af) => new {
|
|
|
- NodeId = ar.NodeId,
|
|
|
+ .Select((ar, af) => new
|
|
|
+ {
|
|
|
+ ar.NodeId,
|
|
|
ar.NodeName,
|
|
|
ar.AuditResult,
|
|
|
ar.AuditorName,
|
|
@@ -3126,14 +3137,15 @@ FROM
|
|
|
var text = new StringBuilder();
|
|
|
auditRecords.ForEach(x =>
|
|
|
{
|
|
|
- var statusText = x.AuditResult switch {
|
|
|
+ var statusText = x.AuditResult switch
|
|
|
+ {
|
|
|
0 => "待审核",
|
|
|
1 => "已审核",
|
|
|
2 => "已拒绝",
|
|
|
3 => "无需处理",
|
|
|
_ => "未知"
|
|
|
};
|
|
|
- var str = $"{x.NodeName}:状态:{statusText} 审核人:{x.AuditorName} 审核时间:{x.AuditTime.ToString("yyyy-MM-dd HH:mm:ss")}<br/>";
|
|
|
+ var str = $"{x.NodeName}:状态:{statusText} 审核人:{x.AuditorName} 审核时间:{x.AuditTime:yyyy-MM-dd HH:mm:ss}<br/>";
|
|
|
text.Append(str);
|
|
|
});
|
|
|
item.StatusDesc = text.ToString();
|
|
@@ -3156,13 +3168,13 @@ FROM
|
|
|
}
|
|
|
else if (item.AuditStatus == GoodsAuditEnum.OutConfirming)
|
|
|
{
|
|
|
- item.IsAuditPer = valuableAuditTemps?.TempNodes.FirstOrDefault(x=> x.NodeOrder == 1)?.NodeUsers.Any(x => x.UserId == currUserId) ?? false;
|
|
|
+ item.IsAuditPer = valuableAuditTemps?.TempNodes.FirstOrDefault(x => x.NodeOrder == 1)?.NodeUsers.Any(x => x.UserId == currUserId) ?? false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//前端权限验证
|
|
|
if (item.IsValuable)
|
|
|
- {
|
|
|
+ {
|
|
|
item.AuditPers = valuableAuditUsers.ToArray();
|
|
|
}
|
|
|
else item.AuditPers = normAuditUsers.ToArray();
|
|
@@ -3244,6 +3256,47 @@ FROM
|
|
|
//物品类型验证
|
|
|
if (_goodsTypeIds.Contains(goodsInfo.Type)) isBatchVail = true;
|
|
|
|
|
|
+ //入库批次关联领用人 更改批次库存
|
|
|
+ var goodsStorages = await _sqlSugar
|
|
|
+ .Queryable<Pm_GoodsStorage>()
|
|
|
+ .Where(x => x.IsDel == 0 &&
|
|
|
+ x.GoodsId == receiveInfo.GoodsId &&
|
|
|
+ (x.Quantity - x.ReceiveQuantity) > 0
|
|
|
+ )
|
|
|
+ .OrderBy(x => x.CreateTime)
|
|
|
+ .ToListAsync();
|
|
|
+
|
|
|
+ var goodsReceiveInfos = new List<GoodsReceiveLinkStorageView>();
|
|
|
+ var batchStorageInfos = new List<Pm_GoodsStorage>();
|
|
|
+ var receiveQuantity = 0.00M; //领用总数量
|
|
|
+ foreach (var storage in goodsStorages)
|
|
|
+ {
|
|
|
+ if (receiveInfo.Quantity == receiveQuantity) break;
|
|
|
+
|
|
|
+ var thisBatchSurplusQuantity = storage.Quantity - storage.ReceiveQuantity;
|
|
|
+ if (thisBatchSurplusQuantity <= 0.00M) continue;
|
|
|
+
|
|
|
+ var thisBatchReceiveQuantity = 0.00M; //此批次领用数量
|
|
|
+ const decimal unit = 0.50M;
|
|
|
+ while (receiveQuantity < receiveInfo.Quantity)
|
|
|
+ {
|
|
|
+ if (thisBatchSurplusQuantity == thisBatchReceiveQuantity) break;
|
|
|
+
|
|
|
+ thisBatchReceiveQuantity += unit;
|
|
|
+ receiveQuantity += unit;
|
|
|
+ }
|
|
|
+ goodsReceiveInfos.Add(new GoodsReceiveLinkStorageView
|
|
|
+ {
|
|
|
+ StorageId = storage.Id,
|
|
|
+ Quantity = thisBatchReceiveQuantity
|
|
|
+ });
|
|
|
+ storage.ReceiveQuantity += thisBatchReceiveQuantity;
|
|
|
+ var storageUpd = storage;
|
|
|
+ //storageUpd.ReceiveQuantity += thisBatchReceiveQuantity;
|
|
|
+ batchStorageInfos.Add(storageUpd);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
goodsIndex++;
|
|
|
}
|
|
|
|
|
@@ -3251,7 +3304,7 @@ FROM
|
|
|
{
|
|
|
receiveInfo.GoodsName = string.Join("、", goodsNames);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//验证领用 添加OR编辑
|
|
|
var goodsReceiveInfo = await _sqlSugar.Queryable<Pm_GoodsReceive>().FirstAsync(x => x.IsDel == 0 && x.Id == goodsReceiveId);
|
|
|
if (goodsReceiveInfo == null) //添加
|
|
@@ -3325,7 +3378,6 @@ FROM
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
#region 审批流程验证、创建
|
|
|
//审核验证 物品含有贵重物品 使用贵重物品审批流程
|
|
|
var auditTempInfo = new ApprovalProcessView();
|
|
@@ -3426,7 +3478,7 @@ FROM
|
|
|
int currUserId = dto.CurrUserId;
|
|
|
string goodsName = dto.GoodsName;
|
|
|
|
|
|
-
|
|
|
+
|
|
|
var showAllPeopleIds = new List<int>() {
|
|
|
374, // 罗颖
|
|
|
233, // 刘华举
|
|
@@ -3437,13 +3489,14 @@ FROM
|
|
|
|
|
|
RefAsync<int> total = 0;
|
|
|
var receiveList = await _sqlSugar.Queryable<Pm_GoodsReceive>()
|
|
|
- .LeftJoin<Sys_Users>((x,y) => x.CreateUserId == y.Id)
|
|
|
- .Where((x, y) => x.IsDel == 0 && x.GoodsId == 0 )
|
|
|
- .WhereIF(!string.IsNullOrEmpty(goodsName), (x,y) => x.GoodsName.Contains(goodsName))
|
|
|
- .WhereIF(!isShowAllPeople,(x,y) => x.CreateUserId == currUserId)
|
|
|
+ .LeftJoin<Sys_Users>((x, y) => x.CreateUserId == y.Id)
|
|
|
+ .Where((x, y) => x.IsDel == 0 && x.GoodsId == 0)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(goodsName), (x, y) => x.GoodsName.Contains(goodsName))
|
|
|
+ .WhereIF(!isShowAllPeople, (x, y) => x.CreateUserId == currUserId)
|
|
|
.OrderByDescending((x, y) => x.CreateTime)
|
|
|
- .Select((x,y) => new GoodsReceiveBatchListView() {
|
|
|
- Id = x.Id,
|
|
|
+ .Select((x, y) => new GoodsReceiveBatchListView()
|
|
|
+ {
|
|
|
+ Id = x.Id,
|
|
|
GoodsName = x.GoodsName,
|
|
|
AccumQty = SqlFunc.Subqueryable<Pm_GoodsReceiveDetails>().Where(z => z.IsDel == 0 && z.GoodsReceiveId == x.Id).Sum(z => z.Quantity),
|
|
|
Reason = x.Reason,
|
|
@@ -3452,7 +3505,7 @@ FROM
|
|
|
Applicant = y.CnName,
|
|
|
ApplyTime = x.CreateTime,
|
|
|
})
|
|
|
- .ToPageListAsync(dto.PageIndex,dto.PageSize,total);
|
|
|
+ .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
|
|
|
|
|
|
foreach (var item in receiveList)
|
|
|
{
|
|
@@ -3511,11 +3564,13 @@ FROM
|
|
|
return _jv;
|
|
|
}
|
|
|
|
|
|
- var info = new GoodsReceiveBatchView();
|
|
|
- info.Id = receiveInfo.Id;
|
|
|
- info.GroupId = receiveInfo.GroupId;
|
|
|
- info.Reason = receiveInfo.Reason;
|
|
|
- info.Remark = receiveInfo.Remark;
|
|
|
+ var info = new GoodsReceiveBatchView
|
|
|
+ {
|
|
|
+ Id = receiveInfo.Id,
|
|
|
+ GroupId = receiveInfo.GroupId,
|
|
|
+ Reason = receiveInfo.Reason,
|
|
|
+ Remark = receiveInfo.Remark,
|
|
|
+ };
|
|
|
info.ReceiveDetails = await _sqlSugar
|
|
|
.Queryable<Pm_GoodsReceiveDetails>()
|
|
|
.LeftJoin<Pm_GoodsInfo>((x, y) => x.GoodsId == y.Id)
|
|
@@ -3529,7 +3584,6 @@ FROM
|
|
|
Remark = x.Remark,
|
|
|
})
|
|
|
.ToArrayAsync();
|
|
|
-
|
|
|
_jv.Code = StatusCodes.Status200OK;
|
|
|
_jv.Msg = $"操作成功!";
|
|
|
_jv.Data = info;
|
|
@@ -3542,12 +3596,12 @@ FROM
|
|
|
/// <param name="id"></param>
|
|
|
/// <param name="currUserId"></param>
|
|
|
/// <returns></returns>
|
|
|
- public async Task<JsonView> GoodsReceiveApproveAsync(int id,int currUserId)
|
|
|
+ public async Task<JsonView> GoodsReceiveApproveAsync(int id, int currUserId)
|
|
|
{
|
|
|
var appId = id;
|
|
|
|
|
|
//验证审核流程
|
|
|
- var flow = await _approvalProcessRep.GetFlowByBusinessAsync(appId,1);
|
|
|
+ var flow = await _approvalProcessRep.GetFlowByBusinessAsync(appId, 1);
|
|
|
if (flow == null)
|
|
|
{
|
|
|
_jv.Msg = $"审核流程不存在";
|
|
@@ -3649,7 +3703,7 @@ FROM
|
|
|
isNodeComplete = nodeRecords.All(x => x.AuditResult == 1);
|
|
|
}
|
|
|
|
|
|
- if (isNodeComplete)
|
|
|
+ if (isNodeComplete)
|
|
|
{
|
|
|
// 查找下一个节点
|
|
|
var nextNode = (await _approvalProcessRep.GetTemplateNodesAsync(flow.TemplateId))
|
|
@@ -3672,11 +3726,12 @@ FROM
|
|
|
return _jv;
|
|
|
}
|
|
|
|
|
|
+ // 扣除库存
|
|
|
var deductStatus = await DeductStockAsync(appId);
|
|
|
|
|
|
if (!deductStatus)
|
|
|
{
|
|
|
- _jv.Msg = $"库存扣除失败失败!";
|
|
|
+ _jv.Msg = $"库存扣除失败!";
|
|
|
_sqlSugar.RollbackTran();
|
|
|
return _jv;
|
|
|
}
|
|
@@ -3924,15 +3979,15 @@ FROM
|
|
|
if (goodsInfo == null) return false;
|
|
|
|
|
|
//1、物品库存扣除
|
|
|
- var receiveQuantity = item.Quantity;
|
|
|
- goodsInfo.StockQuantity -= receiveQuantity;
|
|
|
- goodsInfo.OQ_Total += receiveQuantity;
|
|
|
+ goodsInfo.StockQuantity -= item.Quantity;
|
|
|
+ goodsInfo.OQ_Total += item.Quantity;
|
|
|
|
|
|
//2、入库批次关联领用人 更改批次库存
|
|
|
var goodsStorages = await _sqlSugar
|
|
|
.Queryable<Pm_GoodsStorage>()
|
|
|
.Where(x => x.IsDel == 0 &&
|
|
|
- x.GoodsId == receiveInfo.GoodsId &&
|
|
|
+ x.GoodsId == item.GoodsId &&
|
|
|
+ x.ConfirmStatus == GoodsConfirmEnum.Confirmed &&
|
|
|
(x.Quantity - x.ReceiveQuantity) > 0
|
|
|
)
|
|
|
.OrderBy(x => x.CreateTime)
|
|
@@ -3940,18 +3995,20 @@ FROM
|
|
|
|
|
|
var goodsReceiveInfos = new List<GoodsReceiveLinkStorageView>();
|
|
|
var batchStorageInfos = new List<Pm_GoodsStorage>();
|
|
|
+
|
|
|
+ var receiveQuantity = 0.00M; //领用总数量
|
|
|
foreach (var storage in goodsStorages)
|
|
|
{
|
|
|
- if (receiveInfo.Quantity == receiveQuantity) break;
|
|
|
+ if (item.Quantity == receiveQuantity) break;
|
|
|
|
|
|
var thisBatchSurplusQuantity = storage.Quantity - storage.ReceiveQuantity;
|
|
|
if (thisBatchSurplusQuantity <= 0.00M) continue;
|
|
|
|
|
|
var thisBatchReceiveQuantity = 0.00M; //此批次领用数量
|
|
|
const decimal unit = 0.50M;
|
|
|
- while (receiveQuantity < receiveInfo.Quantity)
|
|
|
+ while (receiveQuantity < storage.Quantity)
|
|
|
{
|
|
|
- if (thisBatchSurplusQuantity == thisBatchReceiveQuantity) break;
|
|
|
+ if (thisBatchSurplusQuantity == thisBatchReceiveQuantity || receiveQuantity == item.Quantity) break;
|
|
|
|
|
|
thisBatchReceiveQuantity += unit;
|
|
|
receiveQuantity += unit;
|