|
@@ -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);
|
|
|
|
|
@@ -1241,7 +1241,7 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
|
|
|
Id = gr.Id,
|
|
|
GroupId = gr.GroupId,
|
|
|
GroupName = di.TeamName,
|
|
|
- GoodsId = gr.GoodsId,
|
|
|
+ GoodsId = grd.GoodsId,
|
|
|
GoodsName = gi.Name,
|
|
|
GoodsTypeId = gi.Type,
|
|
|
GoodsType = sd.Name,
|
|
@@ -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
|
|
|
})
|
|
@@ -1432,6 +1438,17 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //权限前台验证
|
|
|
+ var auditPers = new List<GoodsStorageAuditPerView>
|
|
|
+ {
|
|
|
+ new() { AuditPer = true, AuditDep = GoodsAuditDepEnum.Hr, ButtonText = GoodsAuditDepEnum.Hr_Reception.GetDescription() }
|
|
|
+ };
|
|
|
+ if (_goodsTypeIds.Contains(item.GoodsTypeId))
|
|
|
+ {
|
|
|
+ auditPers.Add(new() { AuditPer = true, AuditDep = GoodsAuditDepEnum.Hr, ButtonText = GoodsAuditDepEnum.Hr.GetDescription() });
|
|
|
+ }
|
|
|
+ item.AuditPers = auditPers.ToArray();
|
|
|
}
|
|
|
|
|
|
if (dto.PortType == 2 || dto.PortType == 3)
|
|
@@ -1503,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";
|
|
@@ -1572,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)
|
|
@@ -1665,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;
|
|
@@ -1752,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)
|
|
@@ -1977,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/>",
|
|
@@ -2181,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/>",
|
|
@@ -2327,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)
|
|
@@ -2397,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)
|
|
|
{
|
|
@@ -2435,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 ? "人事部" : "领用确认";
|
|
@@ -2611,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;
|
|
@@ -2642,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)
|
|
@@ -2669,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;
|
|
|
|
|
@@ -2740,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;
|
|
|
|
|
@@ -2844,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;
|
|
@@ -2873,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)
|
|
@@ -2915,6 +2936,7 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
|
|
|
/// <returns></returns>
|
|
|
public async Task<JsonView> GoodsReceiveDel(int id, int currUserId)
|
|
|
{
|
|
|
+ _jv.Msg = $"操作失败";
|
|
|
var receiveInfo = await _sqlSugar
|
|
|
.Queryable<Pm_GoodsReceive>()
|
|
|
.Where(x => x.IsDel == 0 && x.Id == id)
|
|
@@ -2925,6 +2947,7 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
|
|
|
return _jv;
|
|
|
}
|
|
|
|
|
|
+ _sqlSugar.BeginTran();
|
|
|
var edit = await _sqlSugar
|
|
|
.Updateable<Pm_GoodsReceive>()
|
|
|
.SetColumns(x => new Pm_GoodsReceive()
|
|
@@ -2935,13 +2958,31 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
|
|
|
})
|
|
|
.Where(x => x.Id == id)
|
|
|
.ExecuteCommandAsync();
|
|
|
- if (edit > 0)
|
|
|
+ if (edit < 1)
|
|
|
{
|
|
|
- _jv.Msg = $"操作成功!";
|
|
|
- _jv.Code = StatusCodes.Status200OK;
|
|
|
+ _sqlSugar.RollbackTran();
|
|
|
return _jv;
|
|
|
}
|
|
|
+ var editSub = await _sqlSugar
|
|
|
+ .Updateable<Pm_GoodsReceiveDetails>()
|
|
|
+ .SetColumns(x => new Pm_GoodsReceiveDetails()
|
|
|
+ {
|
|
|
+ IsDel = 1,
|
|
|
+ DeleteUserId = currUserId,
|
|
|
+ DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
|
+ })
|
|
|
+ .Where(x => x.GoodsReceiveId == id)
|
|
|
+ .ExecuteCommandAsync();
|
|
|
|
|
|
+ if (editSub > 0)
|
|
|
+ {
|
|
|
+ _sqlSugar.RollbackTran();
|
|
|
+ return _jv;
|
|
|
+ }
|
|
|
+
|
|
|
+ _sqlSugar.CommitTran();
|
|
|
+ _jv.Msg = $"操作成功!";
|
|
|
+ _jv.Code = StatusCodes.Status200OK;
|
|
|
return _jv;
|
|
|
}
|
|
|
|
|
@@ -3013,8 +3054,13 @@ FROM
|
|
|
) Temp ");
|
|
|
|
|
|
|
|
|
+ var checkValuableUserIds = new List<int>() {
|
|
|
+ 343 , //陈湘OAId
|
|
|
+ 309 , //赖红燕AId
|
|
|
+ };
|
|
|
+
|
|
|
var isValueable = false;
|
|
|
- if (currUserId == 343) //陈湘OAId登录 只显示贵重物品审核信息
|
|
|
+ if (checkValuableUserIds.Contains(currUserId)) //陈湘OAId登录 只显示贵重物品审核信息
|
|
|
{
|
|
|
isValueable = true;
|
|
|
}
|
|
@@ -3024,10 +3070,45 @@ FROM
|
|
|
.WhereIF(!string.IsNullOrEmpty(goodsName), x => x.GoodsName.Contains(goodsName))
|
|
|
.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
|
|
|
|
|
|
+ //普通物品领用审核模板
|
|
|
+ var normAuditTemps = await _approvalProcessRep.GetTemplateByBusinessTypeAsync(2); //普通物品
|
|
|
+
|
|
|
+ var normAuditUsers = new List<GoodsStorageAuditPerView>();
|
|
|
+ normAuditTemps?.TempNodes.ForEach(x =>
|
|
|
+ {
|
|
|
+ var auditDep = GoodsAuditDepEnum.Hr_Reception;
|
|
|
+ if (x.NodeName.Contains("人事部主管/经理审核")) auditDep = GoodsAuditDepEnum.Hr;
|
|
|
+ else if (x.NodeName.Contains("前台审核")) auditDep = GoodsAuditDepEnum.Hr;
|
|
|
+ x.NodeUsers.ForEach(y =>
|
|
|
+ {
|
|
|
+ var userFlang = false;
|
|
|
+ if (y.UserId == currUserId) userFlang = true;
|
|
|
+ var info = new GoodsStorageAuditPerView() { ButtonText = x.NodeName, AuditDep = auditDep, AuditPer = userFlang };
|
|
|
+ normAuditUsers.Add(info);
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ //贵重物品领用审核模板
|
|
|
+ var valuableAuditTemps = await _approvalProcessRep.GetTemplateByBusinessTypeAsync(3); //贵重物品
|
|
|
+ var valuableAuditUsers = new List<GoodsStorageAuditPerView>();
|
|
|
+ valuableAuditTemps?.TempNodes.ForEach(x =>
|
|
|
+ {
|
|
|
+ var auditDep = GoodsAuditDepEnum.Hr_Reception;
|
|
|
+ if (x.NodeName.Contains("人事部主管/经理审核")) auditDep = GoodsAuditDepEnum.Hr;
|
|
|
+ else if (x.NodeName.Contains("前台审核")) auditDep = GoodsAuditDepEnum.Hr;
|
|
|
+ x.NodeUsers.ForEach(y =>
|
|
|
+ {
|
|
|
+ var userFlang = false;
|
|
|
+ if (y.UserId == currUserId) userFlang = true;
|
|
|
+ var info = new GoodsStorageAuditPerView() { ButtonText = x.NodeName, AuditDep = auditDep, AuditPer = userFlang };
|
|
|
+ valuableAuditUsers.Add(info);
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
foreach (var item in view)
|
|
|
{
|
|
|
var details = $"暂无物品信息数据";
|
|
|
-
|
|
|
+
|
|
|
//设置领用详情
|
|
|
if (item.GoodsTypeId < 1)
|
|
|
{
|
|
@@ -3059,16 +3140,17 @@ FROM
|
|
|
details = text.ToString();
|
|
|
}
|
|
|
}
|
|
|
- else details = $"归属团组:{item.GroupName} <br/><br/>物品名称:{item.GoodsName} 物品类型:{item.GoodsType} 领用数量:{item.Quantity} 备注:{item.Remark}<br/>";
|
|
|
+ else details = $"归属团组/类型:{item.GroupName} <br/><br/>物品名称:{item.GoodsName} 物品类型:{item.GoodsType} 领用数量:{item.Quantity} 备注:{item.Remark}<br/>";
|
|
|
|
|
|
item.GoodsDetails = details;
|
|
|
|
|
|
//设置领用状态描述
|
|
|
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,
|
|
@@ -3081,18 +3163,51 @@ 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 auditTime = $"-";
|
|
|
+ if (x.AuditResult == 1 || x.AuditResult == 2 || x.AuditResult == 3) auditTime = x.AuditTime.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
+ var str = $"{x.NodeName}:状态:{statusText} 审核人:{x.AuditorName} 审核时间:{auditTime}<br/>";
|
|
|
text.Append(str);
|
|
|
});
|
|
|
item.StatusDesc = text.ToString();
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ //多情况下审核、操作权限验证
|
|
|
+ if (item.GoodsTypeId == 0)
|
|
|
+ {
|
|
|
+ int tempId = 2;
|
|
|
+ if (item.IsValuable) tempId = 3;
|
|
|
+
|
|
|
+ item.IsAuditPer = await _approvalProcessRep.VerifyAuditAuthAsync(tempId, 1, item.Id, currUserId);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (item.AuditStatus == GoodsAuditEnum.Pending)
|
|
|
+ {
|
|
|
+ item.IsAuditPer = normAuditTemps?.TempNodes.FirstOrDefault()?.NodeUsers.Any(x => x.UserId == currUserId) ?? false;
|
|
|
+ }
|
|
|
+ else if (item.AuditStatus == GoodsAuditEnum.OutConfirming)
|
|
|
+ {
|
|
|
+ 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();
|
|
|
}
|
|
|
|
|
|
if (dto.PortType == 2 || dto.PortType == 3)
|
|
@@ -3171,6 +3286,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++;
|
|
|
}
|
|
|
|
|
@@ -3178,7 +3334,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) //添加
|
|
@@ -3220,29 +3376,30 @@ FROM
|
|
|
return _jv;
|
|
|
}
|
|
|
|
|
|
- //删除旧数据
|
|
|
- var delStatus = await _sqlSugar.Updateable<Pm_GoodsReceiveDetails>()
|
|
|
- .SetColumns(x => new Pm_GoodsReceiveDetails()
|
|
|
- {
|
|
|
- IsDel = 1,
|
|
|
- DeleteUserId = currUserId,
|
|
|
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
|
- })
|
|
|
- .Where(x => x.GoodsReceiveId == goodsReceiveId)
|
|
|
- .ExecuteCommandAsync();
|
|
|
-
|
|
|
- if (delStatus < 1)
|
|
|
- {
|
|
|
- _jv.Msg = $"领用明细旧数据删除失败!";
|
|
|
- _sqlSugar.RollbackTran();
|
|
|
- return _jv;
|
|
|
- }
|
|
|
-
|
|
|
- //添加新明细数据
|
|
|
+ //更新子表数据
|
|
|
if (receiveDetails.Any())
|
|
|
{
|
|
|
- var addStatus = await _sqlSugar.Insertable(receiveDetails).ExecuteCommandAsync();
|
|
|
- if (addStatus < 1)
|
|
|
+ receiveDetails.ForEach(x => { x.GoodsReceiveId = receiveInfo.Id; });
|
|
|
+
|
|
|
+
|
|
|
+ var db_receiveDetails = await _sqlSugar.Queryable<Pm_GoodsReceiveDetails>()
|
|
|
+ .Where(x => x.IsDel == 0 && x.GoodsReceiveId == goodsReceiveId)
|
|
|
+ .ToListAsync();
|
|
|
+
|
|
|
+ var toDelete = db_receiveDetails.Where(p => !receiveDetails.Any(np => np.Id == p.Id)).ToList();
|
|
|
+ if (toDelete.Any())
|
|
|
+ {
|
|
|
+ var delStatus = _sqlSugar.Deleteable(toDelete).ExecuteCommand();
|
|
|
+ if (delStatus < 1)
|
|
|
+ {
|
|
|
+ _jv.Msg = $"领用明细旧数据删除失败!";
|
|
|
+ _sqlSugar.RollbackTran();
|
|
|
+ return _jv;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var addOrUpdStatus = await _sqlSugar.Storageable<Pm_GoodsReceiveDetails>(receiveDetails.ToList()).ExecuteCommandAsync();
|
|
|
+ if (addOrUpdStatus < 1)
|
|
|
{
|
|
|
_jv.Msg = $"领用明细更新失败!";
|
|
|
_sqlSugar.RollbackTran();
|
|
@@ -3251,7 +3408,6 @@ FROM
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
#region 审批流程验证、创建
|
|
|
//审核验证 物品含有贵重物品 使用贵重物品审批流程
|
|
|
var auditTempInfo = new ApprovalProcessView();
|
|
@@ -3337,7 +3493,9 @@ FROM
|
|
|
|
|
|
_sqlSugar.CommitTran();
|
|
|
_jv.Code = StatusCodes.Status200OK;
|
|
|
+ _jv.Data = new { sign = goodsReceiveId };
|
|
|
_jv.Msg = $"操作成功!";
|
|
|
+
|
|
|
return _jv;
|
|
|
}
|
|
|
|
|
@@ -3352,7 +3510,6 @@ FROM
|
|
|
int currUserId = dto.CurrUserId;
|
|
|
string goodsName = dto.GoodsName;
|
|
|
|
|
|
-
|
|
|
var showAllPeopleIds = new List<int>() {
|
|
|
374, // 罗颖
|
|
|
233, // 刘华举
|
|
@@ -3363,13 +3520,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,
|
|
@@ -3378,7 +3536,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)
|
|
|
{
|
|
@@ -3420,7 +3578,6 @@ FROM
|
|
|
return _jv;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 物品领用 批量 详情
|
|
|
/// </summary>
|
|
@@ -3438,11 +3595,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)
|
|
@@ -3456,26 +3615,24 @@ FROM
|
|
|
Remark = x.Remark,
|
|
|
})
|
|
|
.ToArrayAsync();
|
|
|
-
|
|
|
_jv.Code = StatusCodes.Status200OK;
|
|
|
_jv.Msg = $"操作成功!";
|
|
|
_jv.Data = info;
|
|
|
return _jv;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 物品领用 审核 通过
|
|
|
/// </summary>
|
|
|
/// <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 = $"审核流程不存在";
|
|
@@ -3577,7 +3734,7 @@ FROM
|
|
|
isNodeComplete = nodeRecords.All(x => x.AuditResult == 1);
|
|
|
}
|
|
|
|
|
|
- if (isNodeComplete)
|
|
|
+ if (isNodeComplete)
|
|
|
{
|
|
|
// 查找下一个节点
|
|
|
var nextNode = (await _approvalProcessRep.GetTemplateNodesAsync(flow.TemplateId))
|
|
@@ -3600,11 +3757,12 @@ FROM
|
|
|
return _jv;
|
|
|
}
|
|
|
|
|
|
+ // 扣除库存
|
|
|
var deductStatus = await DeductStockAsync(appId);
|
|
|
|
|
|
if (!deductStatus)
|
|
|
{
|
|
|
- _jv.Msg = $"库存扣除失败失败!";
|
|
|
+ _jv.Msg = $"库存扣除失败!";
|
|
|
_sqlSugar.RollbackTran();
|
|
|
return _jv;
|
|
|
}
|
|
@@ -3614,6 +3772,15 @@ FROM
|
|
|
// 进入下一个节点
|
|
|
flow.CurrentNodeId = nextNode.Id;
|
|
|
|
|
|
+ // 更新业务状态为审核中
|
|
|
+ var auditStatus = await UpdateStatusAsync(appId, GoodsAuditEnum.OutConfirming);
|
|
|
+ if (!auditStatus)
|
|
|
+ {
|
|
|
+ _jv.Msg = $"审核状态更新失败!";
|
|
|
+ _sqlSugar.RollbackTran();
|
|
|
+ return _jv;
|
|
|
+ }
|
|
|
+
|
|
|
// 为下一个节点创建审核记录
|
|
|
var nextNodeUsers = await _approvalProcessRep.GetTemplateNodeUsersAsync(nextNode.Id);
|
|
|
var records = nextNodeUsers.Select(user => new Sys_AuditRecord
|
|
@@ -3843,15 +4010,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)
|
|
@@ -3859,18 +4026,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;
|