|
@@ -1,19 +1,16 @@
|
|
|
using AutoMapper;
|
|
|
-using NPOI.SS.Formula.Functions;
|
|
|
+using Microsoft.Extensions.Logging;
|
|
|
+using Serilog;
|
|
|
+using Newtonsoft.Json;
|
|
|
using OASystem.Domain;
|
|
|
using OASystem.Domain.Dtos;
|
|
|
using OASystem.Domain.Dtos.Financial;
|
|
|
+using OASystem.Domain.Dtos.PersonnelModule;
|
|
|
using OASystem.Domain.Entities.Financial;
|
|
|
-using OASystem.Domain.Entities.Groups;
|
|
|
+using OASystem.Domain.Entities.PersonnelModule;
|
|
|
using OASystem.Domain.ViewModels.Financial;
|
|
|
+using OASystem.Infrastructure.Repositories.PersonnelModule;
|
|
|
using OASystem.Infrastructure.Repositories.System;
|
|
|
-using System;
|
|
|
-using System.Collections.Generic;
|
|
|
-using System.ComponentModel.Design;
|
|
|
-using System.Linq;
|
|
|
-using System.Runtime.Intrinsics.Arm;
|
|
|
-using System.Text;
|
|
|
-using System.Threading.Tasks;
|
|
|
|
|
|
namespace OASystem.Infrastructure.Repositories.Financial
|
|
|
{
|
|
@@ -23,9 +20,11 @@ namespace OASystem.Infrastructure.Repositories.Financial
|
|
|
public class DailyFeePaymentRepository : BaseRepository<Fin_DailyFeePayment, Fin_DailyFeePaymentView>
|
|
|
{
|
|
|
private readonly IMapper _mapper;
|
|
|
- private readonly System.SetDataTypeRepository _setDataTypeRep;
|
|
|
- private readonly System.UsersRepository _UsersRep;
|
|
|
- private readonly System.CompanyRepository _CompanyRep;
|
|
|
+ private readonly SetDataTypeRepository _setDataTypeRep;
|
|
|
+ private readonly UsersRepository _UsersRep;
|
|
|
+ private readonly CompanyRepository _CompanyRep;
|
|
|
+ private readonly GoodsRepository _goodsRep;
|
|
|
+ private readonly ILogger<DailyFeePaymentRepository> _logger;
|
|
|
|
|
|
/// <summary>
|
|
|
///
|
|
@@ -35,17 +34,23 @@ namespace OASystem.Infrastructure.Repositories.Financial
|
|
|
/// <param name="setDataTypeRep"></param>
|
|
|
/// <param name="usersRep"></param>
|
|
|
/// <param name="companyRep"></param>
|
|
|
- public DailyFeePaymentRepository(SqlSugarClient sqlSugar,
|
|
|
- IMapper mapper,
|
|
|
- System.SetDataTypeRepository setDataTypeRep,
|
|
|
- UsersRepository usersRep,
|
|
|
- CompanyRepository companyRep)
|
|
|
+ /// <param name="goodsRep"></param>
|
|
|
+ /// <param name="logger"></param>
|
|
|
+ public DailyFeePaymentRepository(SqlSugarClient sqlSugar,
|
|
|
+ IMapper mapper,
|
|
|
+ SetDataTypeRepository setDataTypeRep,
|
|
|
+ UsersRepository usersRep,
|
|
|
+ CompanyRepository companyRep,
|
|
|
+ GoodsRepository goodsRep,
|
|
|
+ ILogger<DailyFeePaymentRepository> logger)
|
|
|
: base(sqlSugar)
|
|
|
{
|
|
|
- this._mapper = mapper;
|
|
|
- this._setDataTypeRep = setDataTypeRep;
|
|
|
- this._UsersRep = usersRep;
|
|
|
- this._CompanyRep = companyRep;
|
|
|
+ _mapper = mapper;
|
|
|
+ _setDataTypeRep = setDataTypeRep;
|
|
|
+ _UsersRep = usersRep;
|
|
|
+ _CompanyRep = companyRep;
|
|
|
+ _goodsRep = goodsRep;
|
|
|
+ _logger = logger;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -114,9 +119,9 @@ namespace OASystem.Infrastructure.Repositories.Financial
|
|
|
else
|
|
|
{
|
|
|
userData.Insert(0, new { Id = -1, CnName = "全部", DepId = 0, DepName = "", JobPostId = 0, JobName = "" });
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
var userData1 = userData.Select(x => new { x.Id, x.CnName }).ToList();
|
|
|
|
|
|
//62 公转 63 私转
|
|
@@ -136,7 +141,7 @@ namespace OASystem.Infrastructure.Repositories.Financial
|
|
|
|
|
|
if (dto.PortType == 1) //web
|
|
|
{
|
|
|
- DailyFeePaymentList = new
|
|
|
+ DailyFeePaymentList = new
|
|
|
{
|
|
|
FeeTypeData = priceTypeData,
|
|
|
FeeSubTypeData = priceSubTypeData,
|
|
@@ -169,6 +174,7 @@ namespace OASystem.Infrastructure.Repositories.Financial
|
|
|
/// 90 Parent 各部门基础固定费用明细
|
|
|
/// 104 Parent 团组费用
|
|
|
/// 672 Sub 办公费用-信息部申请费用
|
|
|
+ /// 1433 Sub 团组/会务储备物资采购
|
|
|
/// </summary>
|
|
|
/// <param name="typeId"></param>
|
|
|
/// <returns></returns>
|
|
@@ -176,14 +182,15 @@ namespace OASystem.Infrastructure.Repositories.Financial
|
|
|
{
|
|
|
if (typeId < 1) return false;
|
|
|
|
|
|
- var parentIds = new List<int>()
|
|
|
- {
|
|
|
+ var parentIds = new List<int>()
|
|
|
+ {
|
|
|
90, // 各部门基础固定费用明细
|
|
|
104, // 团组费用
|
|
|
};
|
|
|
var subIds = new List<int>()
|
|
|
{
|
|
|
- 672, //办公费用-信息部申请费用
|
|
|
+ 672, //办公费用-信息部申请费用
|
|
|
+ 1433, //团组/会务储备物资采购
|
|
|
};
|
|
|
|
|
|
var parentTypeDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && parentIds.Contains(x.STid)).ToListAsync();
|
|
@@ -206,7 +213,7 @@ namespace OASystem.Infrastructure.Repositories.Financial
|
|
|
/// <returns></returns>
|
|
|
public async Task<Result> GetPriceTypeAddData(PortDtoBase dto)
|
|
|
{
|
|
|
- Result result = new Result() { Code = -2 };
|
|
|
+ Result result = new() { Code = -2 };
|
|
|
|
|
|
dynamic? DailyFeePaymentList = null;
|
|
|
|
|
@@ -420,7 +427,7 @@ namespace OASystem.Infrastructure.Repositories.Financial
|
|
|
_fee.GroupId = dto.GroupId;
|
|
|
|
|
|
//自动审核验证
|
|
|
- var auditPer = await GMAutoApprovalType(dto.PriceTypeId);
|
|
|
+ var auditPer = await GMAutoApprovalType(dto.PriceTypeId);
|
|
|
var priceTypeInfo = await _sqlSugar.Queryable<Sys_SetData>().FirstAsync(x => x.IsDel == 0 && x.Id == dto.PriceTypeId);
|
|
|
if (auditPer)
|
|
|
{
|
|
@@ -558,13 +565,13 @@ namespace OASystem.Infrastructure.Repositories.Financial
|
|
|
Result result = new Result() { Code = -2 };
|
|
|
|
|
|
int? delFeeStatus = await _sqlSugar.Updateable<Fin_DailyFeePayment>()
|
|
|
- .Where(a => a.Id == dto.Id)
|
|
|
- .SetColumns(a => new Fin_DailyFeePayment
|
|
|
- {
|
|
|
- IsDel = 1,
|
|
|
- DeleteUserId = dto.Id,
|
|
|
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
|
- }).ExecuteCommandAsync();
|
|
|
+ .Where(a => a.Id == dto.Id)
|
|
|
+ .SetColumns(a => new Fin_DailyFeePayment
|
|
|
+ {
|
|
|
+ IsDel = 1,
|
|
|
+ DeleteUserId = dto.UserId,
|
|
|
+ DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
|
+ }).ExecuteCommandAsync();
|
|
|
|
|
|
result.Code = 0;
|
|
|
return result;
|
|
@@ -581,36 +588,176 @@ namespace OASystem.Infrastructure.Repositories.Financial
|
|
|
|
|
|
if (dto.AuditType == 1) //财务审核
|
|
|
{
|
|
|
- int? auditStatus = await _sqlSugar.Updateable<Fin_DailyFeePayment>()
|
|
|
- .Where(a => a.Id == dto.Id)
|
|
|
- .SetColumns(a => new Fin_DailyFeePayment
|
|
|
- {
|
|
|
- FAudit = dto.AuditStatus,
|
|
|
- FAuditDate = DateTime.Now,
|
|
|
- }).ExecuteCommandAsync();
|
|
|
- if (auditStatus != null && auditStatus > 0)
|
|
|
- result.Code = 0;
|
|
|
- else
|
|
|
- result.Msg = "财务审核操作失败";
|
|
|
+ int auditStatus = await _sqlSugar.Updateable<Fin_DailyFeePayment>()
|
|
|
+ .Where(a => a.Id == dto.Id)
|
|
|
+ .SetColumns(a => new Fin_DailyFeePayment
|
|
|
+ {
|
|
|
+ FAudit = dto.AuditStatus,
|
|
|
+ FAuditDate = DateTime.Now,
|
|
|
+ }).ExecuteCommandAsync();
|
|
|
+ if (auditStatus > 0) result.Code = 0;
|
|
|
+ else result.Msg = "财务审核操作失败";
|
|
|
}
|
|
|
else if (dto.AuditType == 2) //总经理
|
|
|
{
|
|
|
- int? auditStatus = await _sqlSugar.Updateable<Fin_DailyFeePayment>()
|
|
|
- .Where(a => a.Id == dto.Id)
|
|
|
- .SetColumns(a => new Fin_DailyFeePayment
|
|
|
- {
|
|
|
- MAudit = dto.AuditStatus,
|
|
|
- MAuditDate = DateTime.Now,
|
|
|
- }).ExecuteCommandAsync();
|
|
|
-
|
|
|
- if (auditStatus != null && auditStatus > 0)
|
|
|
- result.Code = 0;
|
|
|
- else
|
|
|
- result.Msg = "总经理审核操作失败";
|
|
|
+ int auditStatus = await _sqlSugar.Updateable<Fin_DailyFeePayment>()
|
|
|
+ .Where(a => a.Id == dto.Id)
|
|
|
+ .SetColumns(a => new Fin_DailyFeePayment
|
|
|
+ {
|
|
|
+ MAudit = dto.AuditStatus,
|
|
|
+ MAuditDate = DateTime.Now,
|
|
|
+ }).ExecuteCommandAsync();
|
|
|
+ if (auditStatus > 0) result.Code = 0;
|
|
|
+ else result.Msg = "总经理审核操作失败";
|
|
|
}
|
|
|
+
|
|
|
+ #region 审核完全通过 指定类型 向物资添加信息
|
|
|
+ //费用类型
|
|
|
+ var feeTypeIds = new List<int>() {
|
|
|
+ 1433, //团组/会务储备物资采购
|
|
|
+ 1435, //公司固定物资采购
|
|
|
+ };
|
|
|
+
|
|
|
+ //审核状态集合
|
|
|
+ var auditStatuses = new List<int>() {
|
|
|
+ 1, //审核通过
|
|
|
+ 3, //自动审核
|
|
|
+ };
|
|
|
+
|
|
|
+ var dailyInfo = await _sqlSugar.Queryable<Fin_DailyFeePayment>()
|
|
|
+ .FirstAsync(x => x.Id == dto.Id && x.IsDel == 0 &&
|
|
|
+ auditStatuses.Contains(x.MAudit) &&
|
|
|
+ auditStatuses.Contains(x.FAudit) &&
|
|
|
+ feeTypeIds.Contains(x.PriceTypeId));
|
|
|
+ if (dailyInfo != null)
|
|
|
+ {
|
|
|
+ //执行物资添加、入库、关联信息操作
|
|
|
+ var linkOpRes = await ApplicationLinkGoodsAddAsync(dailyInfo.Id);
|
|
|
+
|
|
|
+ // Updated the logging statement to ensure consistent message templates
|
|
|
+ _logger.LogInformation("【日付申请单关联物品】请求参数:{DailyInfoId}\r\n返回参数:{LinkOpResData}\r\n返回消息:{LinkOpResMsg}",
|
|
|
+ dailyInfo.Id,
|
|
|
+ JsonConvert.SerializeObject(linkOpRes.Data),
|
|
|
+ linkOpRes.Msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 购买申请单关联物品
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="applicatId">日付申请Id</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<JsonView> ApplicationLinkGoodsAddAsync(int applicatId)
|
|
|
+ {
|
|
|
+ if (applicatId < 1) return new JsonView() { Code = StatusCodes.Status400BadRequest, Msg = $"日付申请单ID不正确!" };
|
|
|
+ //if (currUserId < 1) return new JsonView() { Code = StatusCodes.Status400BadRequest, Msg = $"当前登陆人ID不正确!" };
|
|
|
+
|
|
|
+ var dailyInfoRes = await GetSearchById(new Domain.Dtos.Financial.SearchDailyFeePaymentDto() { PortType = 1, Id = applicatId });
|
|
|
+ if (dailyInfoRes.Code != 0) return new JsonView() { Code = StatusCodes.Status400BadRequest, Msg = dailyInfoRes?.Msg ?? "日付申请单信息不存在!" };
|
|
|
+
|
|
|
+ string dynamicJson = JsonConvert.SerializeObject(dailyInfoRes.Data);
|
|
|
+ Fin_DailyFeePaymentInfolView dailyInfo = JsonConvert.DeserializeObject<Fin_DailyFeePaymentInfolView>(dynamicJson);
|
|
|
+
|
|
|
+ if (dailyInfo == null || !dailyInfo.FeeContents.Any())
|
|
|
+ {
|
|
|
+ return new JsonView() { Code = StatusCodes.Status400BadRequest, Msg = $"付申请单信息不存在!!" };
|
|
|
+ }
|
|
|
+
|
|
|
+ //审核验证 总经理 && 财务 审核通过 才可进行 物品添加、入库、关联信息 操作
|
|
|
+ if (dailyInfo.MAudit == 0 || dailyInfo.MAudit == 2 || dailyInfo.FAudit == 0 || dailyInfo.FAudit == 2)
|
|
|
+ {
|
|
|
+ return new JsonView() { Code = StatusCodes.Status400BadRequest, Msg = $"审核未通过,不可进行物资关联信息!" };
|
|
|
+ }
|
|
|
+
|
|
|
+ _sqlSugar.BeginTran();
|
|
|
+
|
|
|
+ //1.验证物品信息
|
|
|
+ var currGoodsTypeId = dailyInfo.PriceTypeId switch
|
|
|
+ {
|
|
|
+ 1433 => 1424, //团组物资
|
|
|
+ 1435 => 1426, //固定资产
|
|
|
+ _ => 0
|
|
|
+ };
|
|
|
+
|
|
|
+ var paras = new List<dynamic>();
|
|
|
+
|
|
|
+ foreach (var item in dailyInfo.FeeContents)
|
|
|
+ {
|
|
|
+ var goodsInfo = await _sqlSugar.Queryable<Pm_GoodsInfo>().FirstAsync(x => x.Name.Equals(item.PriceName) && x.IsDel == 0)
|
|
|
+ ?? new Pm_GoodsInfo()
|
|
|
+ {
|
|
|
+ Id = 0,
|
|
|
+ Name = item.PriceName,
|
|
|
+ Type = currGoodsTypeId,
|
|
|
+ Unit = "-",
|
|
|
+ CreateUserId = dailyInfo.CreateUserId,
|
|
|
+ Remark = $"日付申请模块新增物品信息(需自行更改单位):\n{item.Remark}",
|
|
|
+ };
|
|
|
+ //物品不存在执行添加
|
|
|
+ if (goodsInfo.Id == 0)
|
|
|
+ {
|
|
|
+ goodsInfo.Id = await _sqlSugar.Insertable(goodsInfo).ExecuteReturnIdentityAsync();
|
|
|
+ if (goodsInfo.Id < 1)
|
|
|
+ {
|
|
|
+ _sqlSugar.RollbackTran();
|
|
|
+ return new JsonView() { Code = StatusCodes.Status400BadRequest, Msg = $"物品添加失败!" };
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //执行入库信息添加
|
|
|
+ var storageRes = await _goodsRep.GoodsStorageOp(new GoodsStorageOpDto()
|
|
|
+ {
|
|
|
+ GoodsId = goodsInfo.Id,
|
|
|
+ Quantity = item.Quantity,
|
|
|
+ UnitPrice = item.Price,
|
|
|
+ TotalPrice = item.ItemTotal,
|
|
|
+ SupplierName = "-",
|
|
|
+ SupplierTel = "-",
|
|
|
+ SupplierAddress = "-",
|
|
|
+ SupplierSource = "-",
|
|
|
+ StorageUserId = 374, //固定前台ID为入库人
|
|
|
+ StorageTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
|
+ Remark = $"日付申请模块新增物品入库信息:{item.Remark}",
|
|
|
+ }, 374);
|
|
|
+
|
|
|
+ if (storageRes.Code != StatusCodes.Status200OK)
|
|
|
+ {
|
|
|
+ _sqlSugar.RollbackTran();
|
|
|
+ return new JsonView() { Code = StatusCodes.Status400BadRequest, Msg = $"物品入库信息添加失败!" };
|
|
|
+ }
|
|
|
+ var storageId = Convert.ToInt32(storageRes.Data.GetType().GetProperty("sign").GetValue(storageRes.Data, null) ?? 0);
|
|
|
+
|
|
|
+ //执行关联表添加
|
|
|
+ var addStatus = await _sqlSugar.Insertable(new Fin_ApplicationLinkGoods(
|
|
|
+ id: 0,
|
|
|
+ dailyId: dailyInfo.Id,
|
|
|
+ goodsId: goodsInfo.Id,
|
|
|
+ goodsStorageId: storageId,
|
|
|
+ remark: "",
|
|
|
+ userId: dailyInfo.CreateUserId
|
|
|
+ )).ExecuteCommandAsync();
|
|
|
+ if (addStatus < 1)
|
|
|
+ {
|
|
|
+ _sqlSugar.RollbackTran();
|
|
|
+ return new JsonView() { Code = StatusCodes.Status400BadRequest, Msg = $"日付、物品入库信息关联信息添加失败!" };
|
|
|
+ }
|
|
|
+
|
|
|
+ paras.Add(new
|
|
|
+ {
|
|
|
+ dailyId = dailyInfo.Id,
|
|
|
+ goodsId = goodsInfo.Id,
|
|
|
+ GoodsStorageId = storageId,
|
|
|
+ LinkTableId = addStatus
|
|
|
+ });
|
|
|
+ }
|
|
|
+ _sqlSugar.CommitTran();
|
|
|
+
|
|
|
+ return new JsonView() { Code = StatusCodes.Status200OK, Data = paras, Msg = $"操作成功!" };
|
|
|
+ }
|
|
|
}
|
|
|
}
|