123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413 |
-
- 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();
- var enterExitCostData = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
-
- EnterExitCostInfoView enterExitCostInfoView = new EnterExitCostInfoView();
- if (dto.PortType == 1)
- {
- if (enterExitCostData != null)
- {
- enterExitCostInfoView = _mapper.Map<EnterExitCostInfoView>(enterExitCostData);
- var dayAndCostSql = string.Format(@"Select ntf.Country,ntf.City,ssd.Name CurremcyCode,ssd.Remark CurrencyName,gdac.* From Grp_DayAndCost gdac
- Left Join Grp_NationalTravelFee ntf On ntf.Id = gdac.NationalTravelFeeId
- Left Join Sys_SetData ssd On ssd.STid = 66 And gdac.Currency = ssd.Id
- Where gdac.Isdel = 0 And ntf.IsDel = 0 And gdac.DiId = {0} Order By [Type] ASC,[Days] ASC", 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;
- }
- else result.Msg = ErrorMsg.Error_Port_Msg;
- return result;
- }
-
-
-
-
-
- public async Task<Result> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
- {
- Result result = new Result() { Code = -1, Msg = "操作失败!" };
- #region MyRegion
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- #endregion
- if (dto.SumJJC == 0) {
- dto.OutsideJJPay = 0;
- }
- if (dto.SumGWC == 0) {
- dto.OutsaideGWPay = 0;
- }
- var enterExitCost = _mapper.Map<Grp_EnterExitCost>(dto);
-
- List<Grp_DayAndCost> subData = new List<Grp_DayAndCost>();
- var quarterageData = _mapper.Map<List<Grp_DayAndCost>>(dto.QuarterageData);
- quarterageData = quarterageData.Select(it => { it.CreateUserId = dto.UserId; return it; }).ToList();
- if (quarterageData.Count > 0) subData.AddRange(quarterageData);
- var boardWagesData = _mapper.Map<List<Grp_DayAndCost>>(dto.BoardWagesData);
- boardWagesData = boardWagesData.Select(it => { it.CreateUserId = dto.UserId; return it; }).ToList();
- if (boardWagesData.Count > 0) subData.AddRange(boardWagesData);
- var miscellaneousFeeData = _mapper.Map<List<Grp_DayAndCost>>(dto.MiscellaneousFeeData);
- miscellaneousFeeData = miscellaneousFeeData.Select(it => { it.CreateUserId = dto.UserId; return it; }).ToList();
- if (miscellaneousFeeData.Count > 0) subData.AddRange(miscellaneousFeeData);
- var trainingExpenseData = _mapper.Map<List<Grp_DayAndCost>>(dto.TrainingExpenseData);
- trainingExpenseData = trainingExpenseData.Select(it => { it.CreateUserId = dto.UserId; return it; }).ToList();
- if (trainingExpenseData.Count > 0) subData.AddRange(trainingExpenseData);
-
- enterExitCost.CurrencyRemark = CommonFun.GetCurrencyChinaToString(dto.Currencys);
- enterExitCost.CreateUserId = dto.UserId;
- _sqlSugar.BeginTran();
- if (dto.PortType == 1)
- {
- try
- {
- int enterExitId = 0;
- if (enterExitCost.Id > 0)
- {
- var updateId = _sqlSugar.Updateable<Grp_EnterExitCost>(enterExitCost)
- .IgnoreColumns(it => new { it.DeleteUserId, it.DeleteTime, it.CreateUserId, it.CreateTime, it.IsDel })
- .ExecuteCommand();
- if (updateId > 0)
- {
- enterExitId = enterExitCost.Id;
- }
- else
- {
- _sqlSugar.RollbackTran();
- result.Msg = "修改操作失败!";
- return result;
- }
- }
- else
- {
- enterExitId = _sqlSugar.Insertable<Grp_EnterExitCost>(enterExitCost).ExecuteReturnIdentity();
- if (enterExitId < 1)
- {
- result.Msg = "添加操作失败!";
- return result;
- }
- }
- if (enterExitId > 0)
- {
- string sqlDelete = string.Format(@" Delete From Grp_DayAndCost Where Diid = {0} ", dto.DiId);
- await ExecuteCommandAsync(sqlDelete);
- foreach (var item in subData)
- {
- var updateId = _sqlSugar.Insertable<Grp_DayAndCost>(item).ExecuteCommand();
- if (updateId < 1)
- {
- _sqlSugar.RollbackTran();
- result.Msg = "添加操作失败!";
- return result;
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- _sqlSugar.CommitTran();
- result.Code = 0;
- result.Msg = "操作成功!";
- }
- catch (Exception ex)
- {
- _sqlSugar.RollbackTran();
- result.Msg = ex.Message;
- }
- }
- else result.Msg = ErrorMsg.Error_Port_Msg;
- return result;
- }
-
-
-
-
-
- public async Task<Result> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
- {
- Result result = new Result();
- var data = new Grp_DayAndCost()
- {
- Id = dto.Id,
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
- };
- var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
- if (del > 0) result.Code = 0;
- else result.Msg = string.Format("删除失败!");
- return result;
- }
-
-
-
-
-
- public async Task<Result> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
- {
- Result result = new Result();
- Grp_NationalTravelFee nationalTravelFee = _mapper.Map<Grp_NationalTravelFee>(dto);
- nationalTravelFee.LastUpdateUserId = dto.UserId;
- nationalTravelFee.CreateUserId = dto.UserId;
- if (dto.PortType == 1)
- {
- var _nationalTravelFee = _sqlSugar.Storageable<Grp_NationalTravelFee>(nationalTravelFee).ToStorage();
- if (dto.Id == 0)
- {
- string selectSql = string.Format(@"Select * From Grp_NationalTravelFee
- Where IsDel = 0
- And Continent = '{0}'
- And Country = '{1}'
- And City = '{2}'", dto.Continent, dto.Country, dto.City);
- Grp_NationalTravelFee nationalTravelFee1 = new Grp_NationalTravelFee();
- nationalTravelFee1 = await _sqlSugar.SqlQueryable<Grp_NationalTravelFee>(selectSql).FirstAsync();
- if (nationalTravelFee1 != null)
- {
- result.Msg = "该国家 城市已存在,请勿重复添加!";
- return result;
- }
- _nationalTravelFee.AsInsertable.ExecuteCommand();
- }
- else
- {
- _nationalTravelFee.AsUpdateable
- .IgnoreColumns(it => new { it.CreateUserId, it.CreateTime, it.IsDel })
- .WhereColumns(it => it.Id)
- .ExecuteCommand();
- }
- result.Code = 0;
- }
- else if (dto.PortType == 2)
- {
- }
- else if (dto.PortType == 3)
- {
- }
- else result.Msg = ErrorMsg.Error_Port_Msg;
- return result;
- }
- }
- }
|