|
@@ -0,0 +1,165 @@
|
|
|
+
|
|
|
+using AutoMapper;
|
|
|
+using OASystem.Domain;
|
|
|
+using OASystem.Domain.Dtos.Groups;
|
|
|
+using OASystem.Domain.Entities.Groups;
|
|
|
+using OASystem.Domain.ViewModels.Groups;
|
|
|
+using OASystem.Infrastructure.Repositories.System;
|
|
|
+using OASystem.Infrastructure.Tools;
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using System.Text;
|
|
|
+using System.Threading.Tasks;
|
|
|
+
|
|
|
+namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
+{
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public class EnterExitCostRepository:BaseRepository<Grp_EnterExitCost, EnterExitCostView>
|
|
|
+ {
|
|
|
+ private readonly IMapper _mapper;
|
|
|
+ private readonly SetDataRepository _setDataRep;
|
|
|
+
|
|
|
+
|
|
|
+ public EnterExitCostRepository(SqlSugarClient sqlSugar, IMapper mapper, SetDataRepository setDataRep)
|
|
|
+ :base(sqlSugar)
|
|
|
+ {
|
|
|
+ _setDataRep = setDataRep;
|
|
|
+ _mapper = mapper;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public async Task<Result> SetEnterExitCostCurrencyChange()
|
|
|
+ {
|
|
|
+ Result result = new Result { Code = -1, Msg = "未知错误" };
|
|
|
+
|
|
|
+ var enterExitList = await _sqlSugar.Queryable<Grp_EnterExitCost>().ToListAsync();
|
|
|
+
|
|
|
+ foreach (var item in enterExitList)
|
|
|
+ {
|
|
|
+ string rateStr = string.Format(@"美元(USD):{0}|日元(JPY):{1}|欧元(EUR):{2}|英镑(GBP):{3}|港币(HKD):{4}", item.RateUSD,item.RateJPY,item.RateEUR,item.RateGBP,item.RateHKD);
|
|
|
+ item.CurrencyRemark = rateStr;
|
|
|
+ }
|
|
|
+
|
|
|
+ var res = await _sqlSugar.Updateable(enterExitList)
|
|
|
+ .WhereColumns(it => new { it.Id })
|
|
|
+ .UpdateColumns(it => new { it.CurrencyRemark })
|
|
|
+ .ExecuteCommandAsync();
|
|
|
+
|
|
|
+ if (res > 0)
|
|
|
+ {
|
|
|
+ result.Code = 0;
|
|
|
+ result.Msg = res.ToString();
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public async Task<Result> GetEnterExitCostInfoByDiId(EnterExitCostInfobyDiIdDto dto)
|
|
|
+ {
|
|
|
+ Result result = new Result { Code = -1, Msg = "未知错误" };
|
|
|
+
|
|
|
+ var enterExitCostData = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ EnterExitCostInfoView enterExitCostInfoView = new EnterExitCostInfoView();
|
|
|
+
|
|
|
+ if (enterExitCostData != null)
|
|
|
+ {
|
|
|
+ enterExitCostInfoView = _mapper.Map<EnterExitCostInfoView>(enterExitCostData);
|
|
|
+
|
|
|
+ var dayAndCostSql = string.Format(@"Select ssd.Name CurremcyCode,ssd.Remark CurrencyName,gdac.* From Grp_DayAndCost gdac
|
|
|
+ Left Join Sys_SetData ssd On ssd.STid = 66 And gdac.Currency = ssd.Id
|
|
|
+ Where gdac.Isdel = 0 And gdac.DiId = {0}", dto.DiId);
|
|
|
+ var dayAndCostData = await _sqlSugar.SqlQueryable<DayAndCostInfoView>(dayAndCostSql).ToListAsync();
|
|
|
+
|
|
|
+
|
|
|
+ enterExitCostInfoView.QuarterageData = dayAndCostData.Where(it => it.Type == 1).ToList();
|
|
|
+ enterExitCostInfoView.BoardWagesData = dayAndCostData.Where(it => it.Type == 2).ToList();
|
|
|
+ enterExitCostInfoView.MiscellaneousFeeData =dayAndCostData.Where(it => it.Type == 3).ToList();
|
|
|
+ enterExitCostInfoView.TrainingExpenseData = dayAndCostData.Where(it => it.Type == 4).ToList();
|
|
|
+
|
|
|
+ enterExitCostInfoView.Currencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostData.CurrencyRemark);
|
|
|
+
|
|
|
+ result.Msg = "查询成功";
|
|
|
+ result.Code = 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ result.Msg = "未查询出数据!!!";
|
|
|
+ }
|
|
|
+
|
|
|
+ result.Data = enterExitCostInfoView;
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public async Task<Result> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
|
|
|
+ {
|
|
|
+ Result result = new Result() { Code =-1,Msg="操作失败!" };
|
|
|
+
|
|
|
+ var enterExitCost = _mapper.Map<Grp_EnterExitCost>(dto);
|
|
|
+ var quarterageData = _mapper.Map<List<Grp_DayAndCost>>(dto.QuarterageData);
|
|
|
+ var boardWagesData = _mapper.Map<List<Grp_DayAndCost>>(dto.BoardWagesData);
|
|
|
+ var miscellaneousFeeData = _mapper.Map<List<Grp_DayAndCost>>(dto.MiscellaneousFeeData);
|
|
|
+ var trainingExpenseData = _mapper.Map<List<Grp_DayAndCost>>(dto.TrainingExpenseData);
|
|
|
+
|
|
|
+
|
|
|
+ enterExitCost.CurrencyRemark = CommonFun.GetCurrencyChinaToString(dto.Currencys);
|
|
|
+ _sqlSugar.BeginTran();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var enterExit = _sqlSugar.Storageable<Grp_EnterExitCost>(enterExitCost).ToStorage();
|
|
|
+ enterExit.AsInsertable.ExecuteCommand();
|
|
|
+ enterExit.AsUpdateable.ExecuteCommand();
|
|
|
+
|
|
|
+ var quarterage = _sqlSugar.Storageable<Grp_DayAndCost>(quarterageData).ToStorage();
|
|
|
+ quarterage.AsInsertable.ExecuteCommand();
|
|
|
+ quarterage.AsUpdateable.ExecuteCommand();
|
|
|
+
|
|
|
+ var boardWages = _sqlSugar.Storageable<Grp_DayAndCost>(boardWagesData).ToStorage();
|
|
|
+ boardWages.AsInsertable.ExecuteCommand();
|
|
|
+ boardWages.AsUpdateable.ExecuteCommand();
|
|
|
+
|
|
|
+ var miscellaneousFee = _sqlSugar.Storageable<Grp_DayAndCost>(miscellaneousFeeData).ToStorage();
|
|
|
+ miscellaneousFee.AsInsertable.ExecuteCommand();
|
|
|
+ miscellaneousFee.AsUpdateable.ExecuteCommand();
|
|
|
+
|
|
|
+ var trainingExpense = _sqlSugar.Storageable<Grp_DayAndCost>(trainingExpenseData).ToStorage();
|
|
|
+ trainingExpense.AsInsertable.ExecuteCommand();
|
|
|
+ trainingExpense.AsUpdateable.ExecuteCommand();
|
|
|
+
|
|
|
+ _sqlSugar.CommitTran();
|
|
|
+ result.Code = 0;
|
|
|
+ result.Msg = "操作成功!";
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ _sqlSugar.RollbackTran();
|
|
|
+ result.Msg = ex.Message;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+}
|