소스 검색

Merge branch 'develop' of http://132.232.92.186:3000/XinXiBu/OA2023 into develop

yuanrf 1 주 전
부모
커밋
fc8213b69c

+ 76 - 1
OASystem/OASystem.Api/Controllers/ResourceController.cs

@@ -1,6 +1,7 @@
 using Aspose.Cells;
 using Aspose.Words;
 using EyeSoft.Extensions;
+using NPOI.SS.Formula.PTG;
 using OASystem.API.OAMethodLib;
 using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
 using OASystem.Domain.AesEncryption;
@@ -9,6 +10,7 @@ using OASystem.Domain.Entities.Groups;
 using OASystem.Domain.ViewModels.Groups;
 using OASystem.Infrastructure.Repositories.Groups;
 using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
 using System.Data;
 using System.Diagnostics;
 using System.Linq;
@@ -45,6 +47,7 @@ namespace OASystem.API.Controllers
         private readonly MediaSuppliersRepository _mediaSupplierRep;
         private readonly List<int> _portIds;
         private readonly BasicInsuranceCostRepository _insuranceCostRep;
+        private readonly GamesBudgetMasterRepository _gamesBudgetMasterRep;
 
         public ResourceController(
             IMapper mapper,
@@ -67,7 +70,8 @@ namespace OASystem.API.Controllers
             DelegationInfoRepository delegationInfoRep,
             TranslatorLibraryRepository translatorRep,
             MediaSuppliersRepository mediaSupplierRep,
-            BasicInsuranceCostRepository insuranceCostRep
+            BasicInsuranceCostRepository insuranceCostRep,
+            GamesBudgetMasterRepository gamesBudgetMasterRep
             )
         {
             _mapper = mapper;
@@ -92,6 +96,7 @@ namespace OASystem.API.Controllers
             _mediaSupplierRep = mediaSupplierRep;
             _portIds = new List<int> { 1, 2, 3 };
             _insuranceCostRep = insuranceCostRep;
+            _gamesBudgetMasterRep = gamesBudgetMasterRep;
         }
 
         #region 车公司资料板块
@@ -4801,6 +4806,76 @@ WHERE
             return Ok(JsonView(true));
         }
 
+        #endregion
+
+        #region 世运会成本预算明细
+
+        /// <summary>
+        /// 世运会成本预算明细
+        /// Info
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        [HttpGet("{id}")]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> GamesBudgetMasterInfo([Required(ErrorMessage = "数据编号不能为空!")]int id)
+        {
+            return Ok( await _gamesBudgetMasterRep.InfoAsync(id));
+        }
+
+        /// <summary>
+        /// 世运会成本预算明细
+        /// List
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> GamesBudgetMasterList(GamesBudgetMasterListDto dto)
+        {
+            return Ok(await _gamesBudgetMasterRep.ListAsync(dto));
+        }
+
+        /// <summary>
+        /// 世运会成本预算明细
+        /// OP(Add/Edit)
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> GamesBudgetMasterOP(GamesBudgetMasterOPDto dto)
+        {
+            if (dto.Id > 0)
+            {
+                //修改
+                var editDto = _mapper.Map<GamesBudgetMasterEditDto>(dto);
+                return Ok(await _gamesBudgetMasterRep.EditAsync(editDto));
+            }
+            else if (dto.Id < 1)
+            {
+                //添加
+                var addDto = _mapper.Map<GamesBudgetMasterAddDto>(dto);
+                return Ok(await _gamesBudgetMasterRep.AddAsync(addDto));
+            }
+
+            return Ok(JsonView(false));
+        }
+
+        /// <summary>
+        /// 世运会成本预算明细
+        /// 删除
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> GamesBudgetMasterDel(GamesBudgetMasterDelDto dto)
+        {
+            return Ok(await _gamesBudgetMasterRep.DelAsync(dto));
+        }
+
+
         #endregion
     }
 }

+ 7 - 1
OASystem/OASystem.Domain/AutoMappers/_baseMappingProfile.cs

@@ -300,10 +300,16 @@ namespace OASystem.Domain.AutoMappers
             CreateMap<MediaSupplierAddOrEditDto, Res_MediaSuppliers>();
             #endregion
 
-
             #region 保险国家基础费用
             CreateMap<InsuranceCostOpDto, Res_BasicInsuranceCost>();
             #endregion
+
+            #region 世运会成本预算明细
+            CreateMap<GamesBudgetMasterOPDto, GamesBudgetMasterAddDto>();
+            CreateMap<GamesBudgetMasterOPDto, GamesBudgetMasterEditDto>();
+            CreateMap<GamesBudgetMasterAddDto, Grp_GamesBudgetMaster>();
+            CreateMap<GamesBudgetMasterEditDto, Grp_GamesBudgetMaster>();
+            #endregion
             #endregion
 
             #region Crm

+ 44 - 0
OASystem/OASystem.Domain/Dtos/Resource/GamesBudgetMasterDto.cs

@@ -0,0 +1,44 @@
+using OASystem.Domain.ViewModels.Resource;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.Dtos.Resource
+{
+    public class GamesBudgetMasterDto
+    {
+    }
+
+    public class GamesBudgetMasterListDto : DtoBase
+    {
+        public string Search { get; set; }
+    }
+
+    public class GamesBudgetMasterOPDto : GamesBudgetMasterInfoView
+    {
+        [Range(1,int.MaxValue,ErrorMessage = "请传入有效的UserId!")]
+        public int CurrUserId { get; set; }
+    }
+
+    public class GamesBudgetMasterAddDto : GamesBudgetMasterOPDto
+    {}
+    public class GamesBudgetMasterEditDto : GamesBudgetMasterOPDto
+    { }
+    public class GamesBudgetMasterDelDto 
+    {
+        /// <summary>
+        /// Id
+        /// </summary>
+        [Required(ErrorMessage = "Id不能为空!")]
+        public int Id { get; set; }
+
+        /// <summary>
+        /// 用户ID
+        /// </summary>
+        [Required(ErrorMessage = "用户Id不能为空!")]
+        public int CurrUserId { get; set; }
+    }
+}

+ 7 - 1
OASystem/OASystem.Domain/Entities/Groups/Grp_GamesBudgetMaster‌.cs

@@ -7,11 +7,17 @@ using System.Threading.Tasks;
 namespace OASystem.Domain.Entities.Groups
 {
     /// <summary>
-    /// 世运会成本预算明细‌
+    /// 世运会成本预算明细‌ Grp_GamesBudgetMaster
     /// </summary>
     [SugarTable(tableName: "Grp_GamesBudgetMaster", tableDescription: "世运会成本预算明细")]
     public class Grp_GamesBudgetMaster : EntityBase
     {
+        /// <summary>
+        /// 序号(分页查询使用)
+        /// </summary>
+        [SugarColumn(IsIgnore = true)]
+        public int RowIndex { get; set; }  
+
         /// <summary>
         /// 直属父级
         /// </summary>

+ 90 - 0
OASystem/OASystem.Domain/ViewModels/Resource/GamesBudgetMasterView.cs

@@ -0,0 +1,90 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.ViewModels.Resource
+{
+    public class GamesBudgetMasterView
+    {
+    }
+
+    public class GamesBudgetMasterInfoView 
+    {
+        /// <summary>
+        /// id
+        /// </summary>
+        public int Id { get; set; }
+
+        /// <summary>
+        /// 直属父类
+        /// </summary>
+        [Required(ErrorMessage = "“直属父类”是必填项!")]
+        public string T0 { get; set; }
+
+        /// <summary>
+        /// 工作项目
+        /// </summary>
+        [Required(ErrorMessage = "“工作项目”是必填项!")]
+        public string ProjectWork { get; set; }
+
+        /// <summary>
+        /// 测算内容
+        /// </summary>
+        [Required(ErrorMessage = "“测算内容”是必填项!")]
+        public string CalculationContent { get; set; }
+
+        /// <summary>
+        /// 数量
+        /// </summary>
+        [Required(ErrorMessage = "“数量”是必填项!")]
+        public decimal Quantity { get; set; }
+
+        /// <summary>
+        /// 单位
+        /// </summary>
+        [Required(ErrorMessage = "“单位”是必填项!")]
+        public string Unit { get; set; }
+
+        /// <summary>
+        /// 单价
+        /// </summary>
+        [Required(ErrorMessage = "“单价”不能为空!")]
+        public decimal UnitPrice { get; set; }
+
+        /// <summary>
+        /// 周期-时间
+        /// </summary>
+        public int CycleTime { get; set; }
+        /// <summary>
+        /// 周期-单位
+        /// </summary>
+        public string CycleUnit { get; set; }
+
+        /// <summary>
+        /// 项总金额
+        /// </summary>
+        [Required(ErrorMessage = "“项总金额”不能为空!")]
+        public decimal ItemTotal { get; set; }
+
+        /// <summary>
+        /// 说明
+        /// </summary>
+        public string Specification { get; set; }
+
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string Remark { get; set; }
+    }
+
+    public class GamesBudgetMasterListView : GamesBudgetMasterInfoView
+    {
+        /// <summary>
+        /// 行号
+        /// </summary>
+        public int RowIndex { get; set; }
+    }
+}

+ 158 - 0
OASystem/OASystem.Infrastructure/Repositories/Resource/GamesBudgetMasterRepository.cs

@@ -0,0 +1,158 @@
+using AutoMapper;
+using EyeSoft.Extensions;
+using OASystem.Domain.Dtos.Resource;
+using OASystem.Domain.Entities.Groups;
+using OASystem.Domain.Entities.Resource;
+using OASystem.Domain.ViewModels.Resource;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Infrastructure.Repositories.Resource
+{
+    /// <summary>
+    /// 世运会成本预算 仓储
+    /// </summary>
+    public class GamesBudgetMasterRepository : BaseRepository<Grp_GamesBudgetMaster, Grp_GamesBudgetMaster>
+    {
+        private readonly IMapper _mapper;
+        private readonly JsonView _jv;
+        public GamesBudgetMasterRepository(SqlSugarClient sqlSugar, IMapper mapper) : base(sqlSugar)
+        {
+            _mapper = mapper;
+            _jv = new JsonView() { Code = StatusCodes.Status400BadRequest, Msg = "操作失败!" };
+        }
+
+        /// <summary>
+        /// List
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        public async Task<JsonView> ListAsync(GamesBudgetMasterListDto dto)
+        {
+            _jv.Msg = "暂无数据!";
+            var search = dto.Search;
+            RefAsync<int> total = 0;
+            var infos = await _sqlSugar.Queryable<Grp_GamesBudgetMaster>()
+                .Where(x => x.IsDel == 0)
+                .WhereIF(!string.IsNullOrEmpty(search), x => x.T0.Contains(search) || x.ProjectWork.Contains(search) || x.CalculationContent.Contains(search))
+                .OrderByDescending(x => x.CreateTime)
+                .Select<GamesBudgetMasterListView>()
+                .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
+
+            _jv.Code = StatusCodes.Status200OK;
+            _jv.Msg = $"操作成功!";
+            _jv.Data = infos;
+            _jv.Count = total;
+
+            return _jv;
+        }
+
+        /// <summary>
+        /// 详情
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        public async Task<JsonView> InfoAsync(int id)
+        {
+            _jv.Msg = "暂无数据!";
+            var info = await _sqlSugar.Queryable<Grp_GamesBudgetMaster>()
+                .Where(x => x.IsDel == 0 && x.Id == id)
+                .Select<GamesBudgetMasterInfoView>()
+                .FirstAsync();
+            if (info != null)
+            {
+                _jv.Code = StatusCodes.Status200OK;
+                _jv.Msg = $"操作成功!";
+                _jv.Data = info;
+            }
+
+            return _jv;
+        }
+
+        /// <summary>
+        /// 添加
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        public async Task<JsonView> AddAsync(GamesBudgetMasterAddDto dto)
+        {
+            var info = _mapper.Map<Grp_GamesBudgetMaster>(dto);
+
+            var isNl = await _sqlSugar.Queryable<Grp_GamesBudgetMaster>()
+                .FirstAsync(x => x.IsDel == 0 && 
+                                 (x.T0.Equals(info.T0) || 
+                                 x.ProjectWork.Equals (info.ProjectWork) || 
+                                 x.CalculationContent.Equals(info.CalculationContent)));
+            if (isNl != null)
+            {
+                _jv.Msg = "该项类型费用已存在,请勿重复添加!";
+                return _jv;
+            }
+
+            info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+            info.LastUpdateUserId = dto.CurrUserId;
+            info.CreateTime = DateTime.Now;
+            info.CreateUserId = dto.CurrUserId;
+
+            var insert = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
+            if (insert > 0)
+            {
+                _jv.Msg = "操作成功!";
+                _jv.Code = StatusCodes.Status200OK;
+                return _jv;
+            }
+            return _jv;
+        }
+
+        /// <summary>
+        /// 编辑
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        public async Task<JsonView> EditAsync(GamesBudgetMasterEditDto dto)
+        {
+            var info = _mapper.Map<Grp_GamesBudgetMaster>(dto);
+
+            info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+            info.LastUpdateUserId = dto.CurrUserId;
+
+            var edit = await _sqlSugar.Updateable(info)
+                .IgnoreColumns(x => new { x.CreateTime, x.CreateUserId, x.DeleteTime, x.DeleteUserId, x.IsDel })
+                .ExecuteCommandAsync();
+
+            if (edit > 0)
+            {
+                _jv.Msg = "操作成功!";
+                _jv.Code = StatusCodes.Status200OK;
+                return _jv;
+            }
+            return _jv;
+        }
+
+        /// <summary>
+        /// 删除
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        public async Task<JsonView> DelAsync(GamesBudgetMasterDelDto dto)
+        {
+            var del = await _sqlSugar.Updateable<Grp_GamesBudgetMaster>()
+                .SetColumns(x => x.DeleteUserId == dto.CurrUserId)
+                .SetColumns(x => x.DeleteTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
+                .SetColumns(x => x.IsDel == 1)
+                .Where(x => x.Id == dto.Id)
+                .ExecuteCommandAsync();
+
+            if (del > 0)
+            {
+                _jv.Msg = "操作成功!";
+                _jv.Code = StatusCodes.Status200OK;
+                return _jv;
+            }
+            return _jv;
+        }
+    }
+}