123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525 |
- using Microsoft.AspNetCore.Mvc;
- using NPOI.SS.Formula.Functions;
- using OASystem.API.OAMethodLib.ALiYun;
- using OASystem.API.OAMethodLib.ExcelOutput;
- using OASystem.Domain.Common;
- using OASystem.Domain.Dtos.Business;
- using OASystem.Domain.Dtos.Financial;
- using OASystem.Domain.Dtos.Groups;
- using OASystem.Domain.Entities.Business;
- using OASystem.Domain.Entities.Financial;
- using OASystem.Domain.Entities.Groups;
- using OASystem.Domain.Entities.Resource;
- using OASystem.Domain.ViewModels.Business;
- using OASystem.Domain.ViewModels.Financial;
- using OASystem.Domain.ViewModels.Groups;
- using OASystem.Infrastructure.Repositories.Business;
- using OASystem.Infrastructure.Repositories.Groups;
- using OASystem.Infrastructure.Repositories.System;
- using Org.BouncyCastle.Asn1.Mozilla;
- namespace OASystem.API.Controllers
- {
-
-
-
- [Route("api/[controller]/[action]")]
- public class BusinessController : ControllerBase
- {
- private readonly IMapper _mapper;
- private readonly CommonBusRepository _busRep;
- private readonly SetDataRepository _setDataRep;
- private readonly DelegationInfoRepository _groupRep;
- private readonly TeamRateRepository _teamRateRep;
- public BusinessController( IMapper mapper, CommonBusRepository busRep, SetDataRepository setDataRep, DelegationInfoRepository groupRep, TeamRateRepository teamRateRep)
- {
- _mapper = mapper;
- _busRep = busRep;
- _setDataRep = setDataRep;
- _groupRep = groupRep;
- _teamRateRep = teamRateRep;
- }
- #region 团组信息 团组详情
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostShareGroupInfo(ShareGroupInfoDto dto)
- {
- var groupData = await _groupRep.PostShareGroupInfo(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(groupData.Data));
- }
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetGroupNameList(GroupNameDto dto)
- {
- var groupData = await _groupRep.GetGroupNameList(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(groupData.Data, groupData.Data.Count));
- }
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostGroupDirectionalClassificationInit()
- {
- Result result = new Result();
- result = await _setDataRep.GetSetDataBySTId(_setDataRep, 16);
- if (result.Code != 0)
- {
- return Ok(JsonView(false, "获取失败!"));
- }
- List<SetDataInfoView> _view = JsonConvert.DeserializeObject<List<SetDataInfoView>>(JsonConvert.SerializeObject(result.Data));
- _view.Insert(0, new SetDataInfoView { Id = -1, Name = "所有模块" });
- return Ok(JsonView(_view));
- }
- #endregion
- #region 币种 List
-
-
-
-
- [HttpGet,HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostCurrencyList()
- {
- try
- {
- Result setData = await _setDataRep.GetSetDataBySTId(_setDataRep, 66);
- if (setData.Code == 0)
- {
- return Ok(JsonView(true, "查询成功", setData.Data));
- }
- else
- {
- return Ok(JsonView(false, setData.Msg));
- }
- }
- catch (Exception)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
-
-
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostGroupTeamRateByDiIdAndCTableId(GeneralTeamRateInfoDto dto)
- {
- try
- {
- if (dto == null)
- {
- return Ok(JsonView(false, "请输入参数!"));
- }
- if (dto.DiId == 0)
- {
- return Ok(JsonView(false, "请输入正确的团组Id!"));
- }
- if (dto.CTable == 0)
- {
- return Ok(JsonView(false, "请输入正确的业务类型(CTable)Id!"));
- }
- if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3 )
- {
- string teamRateInfoSql = string.Format(@"Select sd.Name,tr.* From Grp_TeamRate tr
- Left Join Sys_SetData sd On sd.IsDel=0 And sd.STid=16 And tr.CTable = sd.Id
- Where tr.IsDel = 0 And tr.DiId = {0} And tr.CTable = {1}", dto.DiId,dto.CTable);
- var teamRateInfo = await _teamRateRep._sqlSugar.SqlQueryable<TeamRateInfoView>(teamRateInfoSql).ToListAsync();
- #region 团组汇率
- TeamRateModelGeneralView teamRateModels = new TeamRateModelGeneralView();
- #region 单独处理Ctable 币种汇率 默认 为CNY
- if (dto.CTable == 285)
- {
- teamRateModels = new TeamRateModelGeneralView()
- {
- Id = 0,
- CTableId = 285,
- CTableName = "其他款项与收款退还",
- TeamRates = new List<TeamRateDescAddCurrencyIdView>() {
- new TeamRateDescAddCurrencyIdView()
- {
- CurrencyId = 836,
- CurrencyCode = "CNY",
- CurrencyName = "人民币",
- Rate = 1.0000M,
- }
- }
- };
- return Ok(JsonView(true, "操作成功!", teamRateModels));
- }
- #endregion
- List<SetDataInfoView> currencyDatas = new List<SetDataInfoView>();
- #region 获取所有币种
- string sql = string.Format(@"select * from Sys_SetData where STid = {0} and isdel = 0", 66);
- var DBdata = await _setDataRep.GetListBySqlWithNolockAsync(sql);
- if (DBdata == null || DBdata.Count == 0)
- {
- return Ok(JsonView(false, "所有币种获取失败!"));
- }
- currencyDatas = DBdata.Select(x => new SetDataInfoView
- {
- Name = x.Name,
- Id = x.Id,
- Remark = x.Remark,
- }).ToList();
- #endregion
- foreach (TeamRateInfoView item in teamRateInfo)
- {
- TeamRateModelGeneralView teamRateModelInfo = new TeamRateModelGeneralView();
- teamRateModelInfo.Id = item.Id;
- teamRateModelInfo.CTableId = item.CTable;
- teamRateModelInfo.CTableName = item.Name;
- List<TeamRateDescAddCurrencyIdView> teamRateDescViews = new List<TeamRateDescAddCurrencyIdView>();
- #region 拆分remark里的汇率
- if (item.Remark.Contains("|"))
- {
- string[] currencyArr = item.Remark.Split("|");
- foreach (string currency in currencyArr)
- {
- string[] currency1 = currency.Split(":");
- string[] currency2 = currency1[0].Split("(");
- string currencyCode = currency2[1].Replace(")", "").TrimEnd();
- SetDataInfoView dataInfoView = new SetDataInfoView();
- dataInfoView = currencyDatas.Where(it => it.Name == currencyCode).FirstOrDefault();
- int currencyId = currencyDatas.Where(it => it.Name == currencyCode).FirstOrDefault().Id;
- TeamRateDescAddCurrencyIdView rateDescView = new TeamRateDescAddCurrencyIdView()
- {
- CurrencyId = dataInfoView.Id,
- CurrencyCode = currencyCode,
- CurrencyName = currency2[0],
- Rate = decimal.Parse(currency1[1]),
- };
- teamRateDescViews.Add(rateDescView);
- }
- }
- #endregion
- if (teamRateDescViews.Count > 0)
- {
- teamRateDescViews = teamRateDescViews.OrderBy(it => it.CurrencyId).ToList();
- }
- teamRateModelInfo.TeamRates = teamRateDescViews;
- teamRateModels = teamRateModelInfo;
- }
- #endregion
- return Ok(JsonView(true, "操作成功!", teamRateModels));
- }
- else
- {
- return Ok(JsonView(false, "请输入正确的端口号! 1 Web 2 Android 3 Ios;"));
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
-
-
-
-
-
- [HttpGet, HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostCurrencyByDiid(int DiId,int CId,int CurrencyId)
- {
- try
- {
- Result setData = await _setDataRep.PostCurrencyByDiid( DiId, CId, CurrencyId);
- if (setData.Code == 0)
- {
- return Ok(JsonView(true, "查询成功", setData.Data));
- }
- else
- {
- return Ok(JsonView(false, setData.Msg));
- }
- }
- catch (Exception)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- #endregion
- #region 查询页面关联Ctable
-
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostPageLinkCTable(PageLinkCTableDto dto)
- {
- try
- {
- if (dto == null)
- {
- return Ok(JsonView(false, "请求参数不能为空!"));
- }
- if (dto.PageId == 0)
- {
- return Ok(JsonView(false, "页面Id不能为0!"));
- }
- List<CTableCorrelationPageDatas> data = AppSettingsHelper.Get<CTableCorrelationPageDatas>("CTableCorrelationPageDatas");
- CTableCorrelationPageDatas correlationPageDatas = new CTableCorrelationPageDatas();
- foreach (var item in data)
- {
- if (item.PageIdDatas != null)
- {
- var pageId = item.PageIdDatas.Where(it => it == dto.PageId).FirstOrDefault();
- if (pageId != 0)
- {
- correlationPageDatas = item;
- break;
- }
- }
- }
- if (correlationPageDatas.CTableId == 0)
- {
- return Ok(JsonView(false, "您查询的页面Id,未配置AppSettings,请前往配置!"));
- }
- return Ok(JsonView(true, "操作成功",new { CTable = correlationPageDatas.CTableId }));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- #endregion
- #region 会务物料单
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostConferenceList()
- {
- List<Grp_DelegationInfo> listSource = _busRep.Query<Grp_DelegationInfo>(s => s.TeamDid == 691 && s.IsDel == 0).ToList();
- List<GroupNameView> viewList = new List<GroupNameView>();
- foreach (var group in listSource)
- {
- GroupNameView _view = new GroupNameView();
- _view.Id = group.Id;
- _view.GroupName = group.TeamName;
- }
- return Ok(JsonView(viewList));
- }
-
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostConfItemList(int ConfId)
- {
- Bus_ConfItemListView view = new Bus_ConfItemListView();
- Bus_ConfItemListInfo _confListInfo = await _busRep.Query<Bus_ConfItemListInfo>(s => s.Diid == ConfId).FirstAsync();
- if (_confListInfo != null)
- {
- view.TotalCost = _confListInfo.TotalCost;
- string sqlItem = string.Format(@" Select c.Id,c.ItemId,d.ItemName,c.[Count],c.CurrCost,c.OpRemark
- From Bus_ConfItem as c With(Nolock)
- Inner Join Res_ItemDetail as d with(Nolock) On c.ItemId=d.Id
- Where c.ConfListId = {0}", ConfId);
- List<Bus_ConfItemView> confItemList = await _busRep._sqlSugar.SqlQueryable<Bus_ConfItemView>(sqlItem).ToListAsync();
- view.ItemList = new List<Bus_ConfItemView>(confItemList);
- }
- else
- {
- view.ItemList = new List<Bus_ConfItemView>();
- view.TotalCost = 0;
- }
- return Ok(JsonView(view));
- }
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostOptionalItemList()
- {
- List<OptionalBusRangeView> result = await _busRep.GetViewList_OptionalItem();
- return Ok(JsonView(result));
- }
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostEditOptionalItemList(JsonDtoBase jsonDto)
- {
- if (string.IsNullOrEmpty(jsonDto.Paras))
- {
- return Ok(JsonView(false, "参数为空"));
- }
- Edit_OptionalItemListDto _dto = JsonConvert.DeserializeObject<Edit_OptionalItemListDto>(jsonDto.Paras);
-
- if (_dto.DiId < 1)
- {
- return Ok(JsonView(false, "团组Id为空"));
- }
- if (_dto.ConfItemListId < 1)
- {
-
- int rstInsert = await _busRep.Insert_ConfItemList(_dto);
- return Ok(JsonView(rstInsert == 0));
- }
- else
- {
-
- int rstUpdate = await _busRep.Edit_ConfItemList(_dto);
- return Ok(JsonView(rstUpdate == 0));
- }
- return Ok(JsonView(false));
- }
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> Excel_ConfItemList(JsonDtoBase jsonDto)
- {
- if (string.IsNullOrEmpty(jsonDto.Paras))
- {
- return Ok(JsonView(false, "参数为空"));
- }
- dynamic confList = JsonConvert.DeserializeObject<dynamic>(jsonDto.Paras);
- int confListId = confList.ConfListId;
- Bus_ConfItemListInfo _entityConfList = await _busRep.Query<Bus_ConfItemListInfo>(s => s.Id == confListId).FirstAsync();
- if (_entityConfList != null)
- {
- string result = new Excel_BusConfItemList().Excel(_entityConfList);
- }
- else
- {
- return Ok(JsonView(false, "请先保存数据"));
- }
- return Ok(JsonView(false));
- }
- #endregion
- #region 阿里云短信测试
-
-
-
-
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> AliMessageTest(string mobile)
- {
- string add2dayZH = DateTime.Now.AddDays(2).ToString("yyyy年MM月dd日");
- string templateParam = JsonConvert.SerializeObject(new { teams = "测试团组", date = add2dayZH });
- AliMessagePost.PostMessage(mobile, "泛美国际团组", "SMS_461575447", templateParam);
- return Ok(JsonView(true));
- }
- #endregion
- }
- }
|