BusinessController.cs 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814
  1. using Microsoft.AspNetCore.Mvc;
  2. using NPOI.SS.Formula.Functions;
  3. using OASystem.API.OAMethodLib;
  4. using OASystem.API.OAMethodLib.ALiYun;
  5. using OASystem.API.OAMethodLib.ExcelOutput;
  6. using OASystem.Domain.Common;
  7. using OASystem.Domain.Dtos.Baidu;
  8. using OASystem.Domain.Dtos.Business;
  9. using OASystem.Domain.Dtos.CRM;
  10. using OASystem.Domain.Dtos.FileDto;
  11. using OASystem.Domain.Dtos.Financial;
  12. using OASystem.Domain.Dtos.Groups;
  13. using OASystem.Domain.Entities.Business;
  14. using OASystem.Domain.Entities.Customer;
  15. using OASystem.Domain.Entities.Financial;
  16. using OASystem.Domain.Entities.Groups;
  17. using OASystem.Domain.Entities.Resource;
  18. using OASystem.Domain.ViewModels.Business;
  19. using OASystem.Domain.ViewModels.CRM;
  20. using OASystem.Domain.ViewModels.Financial;
  21. using OASystem.Domain.ViewModels.Groups;
  22. using OASystem.Infrastructure.Repositories.Business;
  23. using OASystem.Infrastructure.Repositories.CRM;
  24. using OASystem.Infrastructure.Repositories.Groups;
  25. using OASystem.Infrastructure.Repositories.System;
  26. using Org.BouncyCastle.Asn1.Mozilla;
  27. using StackExchange.Redis;
  28. namespace OASystem.API.Controllers
  29. {
  30. /// <summary>
  31. /// 通用业务操作
  32. /// </summary>
  33. [Route("api/[controller]/[action]")]
  34. public class BusinessController : ControllerBase
  35. {
  36. private readonly IMapper _mapper;
  37. private readonly CommonBusRepository _busRep;
  38. private readonly SetDataRepository _setDataRep;
  39. private readonly DelegationInfoRepository _groupRep;
  40. private readonly TeamRateRepository _teamRateRep;
  41. private readonly TableOperationRecordRepository _TableOperationRecordRep;
  42. public BusinessController( IMapper mapper, CommonBusRepository busRep, SetDataRepository setDataRep, DelegationInfoRepository groupRep, TeamRateRepository teamRateRep,
  43. TableOperationRecordRepository tableOperationRecordRep)
  44. {
  45. _mapper = mapper;
  46. _busRep = busRep;
  47. _setDataRep = setDataRep;
  48. _groupRep = groupRep;
  49. _teamRateRep = teamRateRep;
  50. _TableOperationRecordRep = tableOperationRecordRep;
  51. }
  52. #region 团组信息
  53. /// <summary>
  54. /// 团组信息
  55. /// 团组简略详情
  56. /// </summary>
  57. /// <param name="dto">团组info请求dto</param>
  58. /// <returns></returns>
  59. [HttpPost]
  60. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  61. public async Task<IActionResult> PostShareGroupInfo(ShareGroupInfoDto dto)
  62. {
  63. try
  64. {
  65. var groupData = await _groupRep.PostShareGroupInfo(dto);
  66. if (groupData.Code != 0)
  67. {
  68. return Ok(JsonView(false, groupData.Msg));
  69. }
  70. return Ok(JsonView(groupData.Data));
  71. }
  72. catch (Exception ex)
  73. {
  74. return Ok(JsonView(false, ex.Message));
  75. }
  76. }
  77. /// <summary>
  78. /// 团组信息 团组名称 List
  79. /// </summary>
  80. /// <param name="dto"></param>
  81. /// <returns></returns>
  82. [HttpPost]
  83. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  84. public async Task<IActionResult> GetGroupNameList(GroupNameDto dto)
  85. {
  86. var groupData = await _groupRep.GetGroupNameList(dto);
  87. if (groupData.Code != 0)
  88. {
  89. return Ok(JsonView(false, groupData.Msg));
  90. }
  91. return Ok(JsonView(groupData.Data, groupData.Data.Count));
  92. }
  93. /// <summary>
  94. /// 获取团组指向分类
  95. /// </summary>
  96. /// <param name="_dto">参数Json字符串</param>
  97. /// <returns></returns>
  98. [HttpPost]
  99. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  100. public async Task<IActionResult> PostGroupDirectionalClassificationInit()
  101. {
  102. Result result = new Result();
  103. result = await _setDataRep.GetSetDataBySTId(_setDataRep, 16); //团组指向分类
  104. if (result.Code != 0)
  105. {
  106. return Ok(JsonView(false, "获取失败!"));
  107. }
  108. List<SetDataInfoView> _view1 = JsonConvert.DeserializeObject<List<SetDataInfoView>>(JsonConvert.SerializeObject(result.Data));
  109. SetDataInfoView xc_view = new SetDataInfoView();//77 行程 //移除行程
  110. xc_view = _view1.Where(it => it.Id == 77).FirstOrDefault();
  111. if (xc_view != null) { _view1.Remove(xc_view); };
  112. List<SetDataInfoView> _view = new List<SetDataInfoView>();
  113. //_view.Insert(0, new SetDataInfoView { Id = -1, Name = "所有模块" });
  114. SetDataInfoView qz_view = new SetDataInfoView();//80 签证
  115. qz_view = _view1.Where(it => it.Id == 80).FirstOrDefault();
  116. if (qz_view != null) { _view.Insert(0, qz_view); _view1.Remove(qz_view); };
  117. SetDataInfoView jpyd_view = new SetDataInfoView();//85 机票预订
  118. jpyd_view = _view1.Where(it => it.Id == 85).FirstOrDefault();
  119. if (jpyd_view != null) { _view.Insert(1, jpyd_view); _view1.Remove(jpyd_view); };
  120. SetDataInfoView jdyd_view = new SetDataInfoView();//76 酒店预订
  121. jdyd_view = _view1.Where(it => it.Id == 76).FirstOrDefault();
  122. if (jdyd_view != null) { _view.Insert(2, jdyd_view); _view1.Remove(jdyd_view); };
  123. SetDataInfoView jdzc_view = new SetDataInfoView();//751 酒店早餐
  124. jdzc_view = _view1.Where(it => it.Id == 751).FirstOrDefault();
  125. if (jdzc_view != null) {
  126. _view1.Remove(jdzc_view);
  127. //_view.Insert(3, jdzc_view); _view1.Remove(jdzc_view);
  128. };
  129. SetDataInfoView cdy_view = new SetDataInfoView();//79 车/导游地接
  130. cdy_view = _view1.Where(it => it.Id == 79).FirstOrDefault();
  131. if (cdy_view != null) { _view.Insert(3, cdy_view); _view1.Remove(cdy_view); };
  132. SetDataInfoView yqgw_view = new SetDataInfoView();//81 邀请/公务活动
  133. yqgw_view = _view1.Where(it => it.Id == 81).FirstOrDefault();
  134. if (yqgw_view != null) { _view.Insert(4, yqgw_view); _view1.Remove(yqgw_view); };
  135. SetDataInfoView bx_view = new SetDataInfoView();//82 团组客户保险
  136. bx_view = _view1.Where(it => it.Id == 82).FirstOrDefault();
  137. if (bx_view != null) { _view.Insert(5, bx_view); _view1.Remove(bx_view); };
  138. SetDataInfoView qtkx_view = new SetDataInfoView();//98 其他款项
  139. qtkx_view = _view1.Where(it => it.Id == 98).FirstOrDefault();
  140. if (qtkx_view != null) { _view.Insert(6, qtkx_view); _view1.Remove(qtkx_view); };
  141. SetDataInfoView skth_view = new SetDataInfoView();//285 收款退还与其他款项
  142. skth_view = _view1.Where(it => it.Id == 285).FirstOrDefault();
  143. if (skth_view != null) { _view.Insert(7, skth_view); _view1.Remove(skth_view); };
  144. if (_view1.Count > 0)
  145. {
  146. _view.AddRange(_view1);
  147. }
  148. return Ok(JsonView(_view));
  149. }
  150. /// <summary>
  151. /// 查询团组简略详情列表
  152. /// Page 根据Ctable And User 返回可操作的团
  153. /// </summary>
  154. /// <param name="dto"></param>
  155. /// <returns></returns>
  156. [HttpPost]
  157. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  158. public async Task<IActionResult> PostGroupListByCTableAndUserId(GroupListByCTableAndUserIdDto dto)
  159. {
  160. if (dto.CTable < 1) Ok(JsonView(false, @"请输入正确的员工给Id!"));
  161. if (dto.CTable < 1)
  162. return Ok(JsonView(false, @"请输入正确的CTable Id !76 酒店预订 77 行程 79 车/导游地接<br/>80 签证 81 邀请/公务活动 82 团组客户保险<br\>85 机票预订 98 其他款项 751 酒店早餐"));
  163. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3)
  164. {
  165. string sql = string.Format(@"Select row_number() over(order by di.VisitStartDate Desc) as Row_Number,
  166. di.Id,di.TeamName,di.TourCode,di.ClientName,di.VisitCountry,di.VisitStartDate,
  167. di.VisitEndDate,di.VisitDays,di.VisitPNumber
  168. From Grp_GroupsTaskAssignment gta
  169. Inner Join Grp_DelegationInfo di On gta.DIId = di.Id
  170. Where gta.IsDel = 0 And di.IsDel = 0 And gta.IsEnable = 1
  171. And gta.CTId = {0} And gta.UId = {1}", dto.CTable, dto.UserId);
  172. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  173. var data = await _groupRep._sqlSugar.SqlQueryable<GroupListByCTableAndUserIdView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total); //ToPageAsync
  174. foreach (var item in data)
  175. {
  176. item.VisitStartDate = item.VisitStartDate == "" ? "" : Convert.ToDateTime(item.VisitStartDate).ToString("yyyy-MM-dd");
  177. item.VisitEndDate = item.VisitEndDate == "" ? "" : Convert.ToDateTime(item.VisitEndDate).ToString("yyyy-MM-dd");
  178. }
  179. return Ok(JsonView(true, "操作成功!", data, total));
  180. }
  181. else
  182. {
  183. return Ok(JsonView(false, @"请输入正确的PortType 1 Web 2 Android 3 IOS "));
  184. }
  185. }
  186. #endregion
  187. #region 币种 List
  188. /// <summary>
  189. /// 币种 List
  190. /// </summary>
  191. /// <returns></returns>
  192. [HttpGet,HttpPost]
  193. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  194. public async Task<IActionResult> PostCurrencyList()
  195. {
  196. try
  197. {
  198. Result setData = await _setDataRep.GetSetDataBySTId(_setDataRep, 66); //币种类型
  199. if (setData.Code == 0)
  200. {
  201. return Ok(JsonView(true, "查询成功", setData.Data));
  202. }
  203. else
  204. {
  205. return Ok(JsonView(false, setData.Msg));
  206. }
  207. }
  208. catch (Exception)
  209. {
  210. return Ok(JsonView(false, "程序错误!"));
  211. throw;
  212. }
  213. }
  214. /// <summary>
  215. /// 团组汇率 币种 Item (来源:团组汇率)
  216. /// 根据 团组Id And 业务类型(CTable)Id
  217. /// api处理CTable = 285,默认返回CNY
  218. /// </summary>
  219. /// <param name="dto"> 请求参数Dto </param>
  220. /// <returns></returns>
  221. [HttpPost]
  222. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  223. public async Task<IActionResult> PostGroupTeamRateByDiIdAndCTableId(GeneralTeamRateInfoDto dto)
  224. {
  225. try
  226. {
  227. if (dto == null)
  228. {
  229. return Ok(JsonView(false, "请输入参数!"));
  230. }
  231. if (dto.DiId == 0)
  232. {
  233. return Ok(JsonView(false, "请输入正确的团组Id!"));
  234. }
  235. if (dto.CTable == 0)
  236. {
  237. return Ok(JsonView(false, "请输入正确的业务类型(CTable)Id!"));
  238. }
  239. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3 )
  240. {
  241. string teamRateInfoSql = string.Format(@"Select sd.Name,tr.* From Grp_TeamRate tr
  242. Left Join Sys_SetData sd On sd.IsDel=0 And sd.STid=16 And tr.CTable = sd.Id
  243. Where tr.IsDel = 0 And tr.DiId = {0} And tr.CTable = {1}", dto.DiId,dto.CTable);
  244. var teamRateInfo = await _teamRateRep._sqlSugar.SqlQueryable<TeamRateInfoView>(teamRateInfoSql).ToListAsync();
  245. #region 团组汇率
  246. TeamRateModelGeneralView teamRateModels = new TeamRateModelGeneralView();
  247. #region 单独处理Ctable 币种汇率 默认 为CNY
  248. if (dto.CTable == 285)
  249. {
  250. teamRateModels = new TeamRateModelGeneralView()
  251. {
  252. Id = 0,
  253. CTableId = 285,
  254. CTableName = "其他款项与收款退还",
  255. TeamRates = new List<TeamRateDescAddCurrencyIdView>() {
  256. new TeamRateDescAddCurrencyIdView()
  257. {
  258. CurrencyId = 836,
  259. CurrencyCode = "CNY",
  260. CurrencyName = "人民币",
  261. Rate = 1.0000M,
  262. }
  263. }
  264. };
  265. return Ok(JsonView(true, "操作成功!", teamRateModels));
  266. }
  267. #endregion
  268. List<SetDataInfoView> currencyDatas = new List<SetDataInfoView>();
  269. #region 获取所有币种
  270. string sql = string.Format(@"select * from Sys_SetData where STid = {0} and isdel = 0", 66);
  271. var DBdata = await _setDataRep.GetListBySqlWithNolockAsync(sql);
  272. if (DBdata == null || DBdata.Count == 0)
  273. {
  274. return Ok(JsonView(false, "所有币种获取失败!"));
  275. }
  276. currencyDatas = DBdata.Select(x => new SetDataInfoView
  277. {
  278. Name = x.Name,
  279. Id = x.Id,
  280. Remark = x.Remark,
  281. }).ToList();
  282. #endregion
  283. foreach (TeamRateInfoView item in teamRateInfo)
  284. {
  285. TeamRateModelGeneralView teamRateModelInfo = new TeamRateModelGeneralView();
  286. teamRateModelInfo.Id = item.Id;
  287. teamRateModelInfo.CTableId = item.CTable;
  288. teamRateModelInfo.CTableName = item.Name;
  289. List<TeamRateDescAddCurrencyIdView> teamRateDescViews = new List<TeamRateDescAddCurrencyIdView>();
  290. #region 拆分remark里的汇率
  291. if (item.Remark.Contains("|"))
  292. {
  293. string[] currencyArr = item.Remark.Split("|");
  294. foreach (string currency in currencyArr)
  295. {
  296. string[] currency1 = currency.Split(":");
  297. string[] currency2 = currency1[0].Split("(");
  298. string currencyCode = currency2[1].Replace(")", "").TrimEnd();
  299. SetDataInfoView dataInfoView = new SetDataInfoView();
  300. dataInfoView = currencyDatas.Where(it => it.Name == currencyCode).FirstOrDefault();
  301. int currencyId = currencyDatas.Where(it => it.Name == currencyCode).FirstOrDefault().Id;
  302. TeamRateDescAddCurrencyIdView rateDescView = new TeamRateDescAddCurrencyIdView()
  303. {
  304. CurrencyId = dataInfoView.Id,
  305. CurrencyCode = currencyCode,
  306. CurrencyName = currency2[0],
  307. Rate = decimal.Parse(currency1[1]),
  308. };
  309. teamRateDescViews.Add(rateDescView);
  310. }
  311. }
  312. else
  313. {
  314. if (!string.IsNullOrEmpty(item.Remark))
  315. {
  316. string[] currency1 = item.Remark.Split(":");
  317. string[] currency2 = currency1[0].Split("(");
  318. string currencyCode = currency2[1].Replace(")", "").TrimEnd();
  319. SetDataInfoView dataInfoView = new SetDataInfoView();
  320. dataInfoView = currencyDatas.Where(it => it.Name == currencyCode).FirstOrDefault();
  321. int currencyId = currencyDatas.Where(it => it.Name == currencyCode).FirstOrDefault().Id;
  322. TeamRateDescAddCurrencyIdView rateDescView = new TeamRateDescAddCurrencyIdView()
  323. {
  324. CurrencyId = dataInfoView.Id,
  325. CurrencyCode = currencyCode,
  326. CurrencyName = currency2[0],
  327. Rate = decimal.Parse(currency1[1]),
  328. };
  329. teamRateDescViews.Add(rateDescView);
  330. }
  331. }
  332. #endregion
  333. if (teamRateDescViews.Count > 0)
  334. {
  335. teamRateDescViews = teamRateDescViews.OrderBy(it => it.CurrencyId).ToList();
  336. }
  337. teamRateModelInfo.TeamRates = teamRateDescViews;
  338. teamRateModels = teamRateModelInfo;
  339. }
  340. if (teamRateModels.TeamRates == null)
  341. {
  342. teamRateModels.TeamRates = new List<TeamRateDescAddCurrencyIdView>();
  343. }
  344. #endregion
  345. return Ok(JsonView(true, "操作成功!", teamRateModels));
  346. }
  347. else
  348. {
  349. return Ok(JsonView(false, "请输入正确的端口号! 1 Web 2 Android 3 Ios;"));
  350. }
  351. }
  352. catch (Exception ex)
  353. {
  354. return Ok(JsonView(false, ex.Message));
  355. }
  356. }
  357. /// <summary>
  358. /// 根据团组Id币种Id及类型Id查询团组汇率
  359. /// </summary>
  360. /// <param name="dto"></param>
  361. /// <returns></returns>
  362. [HttpGet, HttpPost]
  363. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  364. public async Task<IActionResult> PostCurrencyByDiid(int DiId,int CId,int CurrencyId)
  365. {
  366. try
  367. {
  368. Result setData = await _setDataRep.PostCurrencyByDiid( DiId, CId, CurrencyId); //币种类型
  369. if (setData.Code == 0)
  370. {
  371. return Ok(JsonView(true, "查询成功", setData.Data));
  372. }
  373. else
  374. {
  375. return Ok(JsonView(false, setData.Msg));
  376. }
  377. }
  378. catch (Exception)
  379. {
  380. return Ok(JsonView(false, "程序错误!"));
  381. throw;
  382. }
  383. }
  384. #endregion
  385. #region 查询页面关联Ctable
  386. /// <summary>
  387. /// 页面关联Ctable
  388. /// 根据PageId 返回 CTable Id
  389. /// </summary>
  390. /// <param name="dto"></param>
  391. /// <returns></returns>
  392. [HttpPost]
  393. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  394. public async Task<IActionResult> PostPageLinkCTable(PageLinkCTableDto dto)
  395. {
  396. try
  397. {
  398. if (dto == null)
  399. {
  400. return Ok(JsonView(false, "请求参数不能为空!"));
  401. }
  402. if (dto.PageId == 0)
  403. {
  404. return Ok(JsonView(false, "页面Id不能为0!"));
  405. }
  406. List<CTableCorrelationPageDatas> data = AppSettingsHelper.Get<CTableCorrelationPageDatas>("CTableCorrelationPageDatas");
  407. CTableCorrelationPageDatas correlationPageDatas = new CTableCorrelationPageDatas();
  408. foreach (var item in data)
  409. {
  410. if (item.PageIdDatas != null)
  411. {
  412. var pageId = item.PageIdDatas.Where(it => it == dto.PageId).FirstOrDefault();
  413. if (pageId != 0)
  414. {
  415. correlationPageDatas = item;
  416. break;
  417. }
  418. }
  419. }
  420. if (correlationPageDatas.CTableId == 0)
  421. {
  422. return Ok(JsonView(false, "您查询的页面Id,未配置AppSettings,请前往配置!"));
  423. }
  424. return Ok(JsonView(true, "操作成功",new { CTable = correlationPageDatas.CTableId }));
  425. }
  426. catch (Exception ex)
  427. {
  428. return Ok(JsonView(false, ex.Message));
  429. }
  430. }
  431. #endregion
  432. #region 会务物料单
  433. /// <summary>
  434. /// 获取会务活动列表
  435. /// </summary>
  436. /// <param name="paras"></param>
  437. /// <returns></returns>
  438. [HttpPost]
  439. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  440. public async Task<IActionResult> PostConferenceList()
  441. {
  442. List<Grp_DelegationInfo> listSource = _busRep.Query<Grp_DelegationInfo>(s => s.TeamDid == 691 && s.IsDel == 0).ToList();
  443. List<GroupNameView> viewList = new List<GroupNameView>();
  444. foreach (var group in listSource)
  445. {
  446. GroupNameView _view = new GroupNameView();
  447. _view.Id = group.Id;
  448. _view.GroupName = group.TeamName;
  449. }
  450. return Ok(JsonView(viewList));
  451. }
  452. /// <summary>
  453. /// 获取会务的采购物品计划清单
  454. /// </summary>
  455. /// <param name="ConfId">会务活动Id</param>
  456. /// <returns></returns>
  457. [HttpPost]
  458. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  459. public async Task<IActionResult> PostConfItemList(int ConfId)
  460. {
  461. Bus_ConfItemListView view = new Bus_ConfItemListView();
  462. Bus_ConfItemListInfo _confListInfo = await _busRep.Query<Bus_ConfItemListInfo>(s => s.Diid == ConfId).FirstAsync();
  463. if (_confListInfo != null)
  464. {
  465. view.TotalCost = _confListInfo.TotalCost;
  466. string sqlItem = string.Format(@" Select c.Id,c.ItemId,d.ItemName,c.[Count],c.CurrCost,c.OpRemark
  467. From Bus_ConfItem as c With(Nolock)
  468. Inner Join Res_ItemDetail as d with(Nolock) On c.ItemId=d.Id
  469. Where c.ConfListId = {0}", ConfId);
  470. List<Bus_ConfItemView> confItemList = await _busRep._sqlSugar.SqlQueryable<Bus_ConfItemView>(sqlItem).ToListAsync();
  471. view.ItemList = new List<Bus_ConfItemView>(confItemList);
  472. }
  473. else
  474. {
  475. view.ItemList = new List<Bus_ConfItemView>();
  476. view.TotalCost = 0;
  477. }
  478. return Ok(JsonView(view));
  479. }
  480. /// <summary>
  481. /// 获取会务可采购的物料集合
  482. /// </summary>
  483. /// <returns></returns>
  484. [HttpPost]
  485. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  486. public async Task<IActionResult> PostOptionalItemList()
  487. {
  488. List<OptionalBusRangeView> result = await _busRep.GetViewList_OptionalItem();
  489. return Ok(JsonView(result));
  490. }
  491. /// <summary>
  492. /// 编辑物料采购清单
  493. /// </summary>
  494. /// <returns></returns>
  495. [HttpPost]
  496. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  497. public async Task<IActionResult> PostEditOptionalItemList(JsonDtoBase jsonDto)
  498. {
  499. if (string.IsNullOrEmpty(jsonDto.Paras))
  500. {
  501. return Ok(JsonView(false, "参数为空"));
  502. }
  503. Edit_OptionalItemListDto _dto = JsonConvert.DeserializeObject<Edit_OptionalItemListDto>(jsonDto.Paras);
  504. //Edit_OptionalItemListDto _dto = System.Text.Json.JsonSerializer.Deserialize<Edit_OptionalItemListDto>(jsonDto.Paras);
  505. if (_dto.DiId < 1)
  506. {
  507. return Ok(JsonView(false, "团组Id为空"));
  508. }
  509. if (_dto.ConfItemListId < 1)
  510. {
  511. //新增
  512. int rstInsert = await _busRep.Insert_ConfItemList(_dto);
  513. return Ok(JsonView(rstInsert == 0));
  514. }
  515. else
  516. {
  517. //修改
  518. int rstUpdate = await _busRep.Edit_ConfItemList(_dto);
  519. return Ok(JsonView(rstUpdate == 0));
  520. }
  521. return Ok(JsonView(false));
  522. }
  523. /// <summary>
  524. /// 获取会务采购物料清单Excel
  525. /// </summary>
  526. /// <returns></returns>
  527. [HttpPost]
  528. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  529. public async Task<IActionResult> Excel_ConfItemList(JsonDtoBase jsonDto)
  530. {
  531. if (string.IsNullOrEmpty(jsonDto.Paras))
  532. {
  533. return Ok(JsonView(false, "参数为空"));
  534. }
  535. dynamic confList = JsonConvert.DeserializeObject<dynamic>(jsonDto.Paras);
  536. int confListId = confList.ConfListId;
  537. Bus_ConfItemListInfo _entityConfList = await _busRep.Query<Bus_ConfItemListInfo>(s => s.Id == confListId).FirstAsync();
  538. if (_entityConfList != null)
  539. {
  540. string result = new Excel_BusConfItemList().Excel(_entityConfList);
  541. }
  542. else
  543. {
  544. return Ok(JsonView(false, "请先保存数据"));
  545. }
  546. return Ok(JsonView(false));
  547. }
  548. #endregion
  549. #region 阿里云短信测试
  550. /// <summary>
  551. /// 编辑物料采购清单
  552. /// </summary>
  553. /// <returns></returns>
  554. [HttpPost]
  555. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  556. public async Task<IActionResult> AliMessageTest(string mobile)
  557. {
  558. string add2dayZH = DateTime.Now.AddDays(2).ToString("yyyy年MM月dd日");
  559. string templateParam = JsonConvert.SerializeObject(new { teams = "测试团组", date = add2dayZH });
  560. AliMessagePost.PostMessage(mobile, "泛美国际团组", "SMS_461575447", templateParam);
  561. return Ok(JsonView(true));
  562. }
  563. #endregion
  564. #region 文件删除
  565. /// <summary>
  566. /// 文件操作
  567. /// 删除指定文件
  568. /// </summary>
  569. /// <param name="dto">Dto</param>
  570. /// <returns></returns>
  571. [HttpPost]
  572. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  573. public async Task<IActionResult> PostFileDel(FileDelDto dto)
  574. {
  575. try
  576. {
  577. string pathUrl = dto.PathUrl;
  578. if (string.IsNullOrEmpty(pathUrl))
  579. return Ok(JsonView(false, "路径为空或者不是有效路径!"));
  580. if (System.IO.File.Exists(pathUrl))
  581. {
  582. System.IO.File.Delete(pathUrl);
  583. return Ok(JsonView(false, "操作成功!"));
  584. }
  585. else
  586. {
  587. return Ok(JsonView(false, "该文件不存在!"));
  588. }
  589. }
  590. catch (Exception ex)
  591. {
  592. return Ok(JsonView(false, ex.Message));
  593. }
  594. }
  595. #endregion
  596. #region 表操作记录
  597. /// <summary>
  598. /// 表操作记录
  599. /// 添加
  600. /// </summary>
  601. /// <returns></returns>
  602. [HttpPost]
  603. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  604. public async Task<IActionResult> PostTableOperationRecordAdd(TableOperationRecordAddDto _dto )
  605. {
  606. try
  607. {
  608. Crm_TableOperationRecord _TableOperationRecord = new Crm_TableOperationRecord()
  609. {
  610. TableName = _dto.TableName,
  611. PortType = _dto.PortType,
  612. OperationItem = _dto.OperationItem,
  613. DataId = _dto.DataId,
  614. CreateUserId = _dto.UserId,
  615. CreateTime = DateTime.Now,
  616. Remark = "",
  617. IsDel = 0
  618. };
  619. bool _view = await _TableOperationRecordRep._Add(_TableOperationRecord);
  620. if (_view)
  621. {
  622. return Ok(JsonView(true,"操作成功!"));
  623. }
  624. else
  625. {
  626. return Ok(JsonView(false,"操作失败!"));
  627. }
  628. }
  629. catch (Exception)
  630. {
  631. return Ok(JsonView(false, "程序错误!"));
  632. }
  633. }
  634. /// <summary>
  635. /// 表操作记录
  636. /// 分页
  637. /// </summary>
  638. /// <returns></returns>
  639. [HttpPost]
  640. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  641. public async Task<IActionResult> PostTableOperationRecordPageList(TableOperationRecordPageDto _dto)
  642. {
  643. try
  644. {
  645. string whereSql = "";
  646. if (!string.IsNullOrEmpty(_dto.TableName))
  647. {
  648. whereSql = string.Format(" And tor.TableName = '{0}'", _dto.TableName);
  649. }
  650. string sql = string.Format(@"Select row_number() over(order by tor.CreateTime Desc) As Row_Number,
  651. tor.TableName,tor.PortType,tor.OperationItem,tor.DataId,u.CnName As OperationUserName,
  652. tor.CreateTime,tor.Remark
  653. From Crm_TableOperationRecord tor
  654. Left Join Sys_Users u On tor.CreateUserId = u.Id
  655. Where tor.Isdel = 0 {0}", whereSql);
  656. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  657. var _view = await _TableOperationRecordRep._sqlSugar.SqlQueryable<TableOperationRecordPageView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  658. return Ok(JsonView(true, "查询成功!", _view, total));
  659. }
  660. catch (Exception ex)
  661. {
  662. return Ok(JsonView(false, "程序错误!Msg:" + ex.Message));
  663. }
  664. }
  665. #endregion
  666. /// <summary>
  667. /// 汉字转拼音
  668. /// </summary>
  669. /// <param name="dto"></param>
  670. /// <returns></returns>
  671. [HttpPost]
  672. public IActionResult ChineseToEnFn(ChineseToEn dto)
  673. {
  674. var jw = JsonView(false, "请输入中文!");
  675. if (dto.originalText.Count == 0)
  676. {
  677. return Ok(jw);
  678. }
  679. List<string> values = new List<string>();
  680. foreach (var item in dto.originalText)
  681. {
  682. var val = item.GetTotalPingYin();
  683. if (dto.isUp)
  684. {
  685. val = val.Select(x => x.ToUpper()).ToList();
  686. }
  687. values.Add(val.Count > 0 ? val[0]: "暂无该拼音!");
  688. }
  689. jw = JsonView(true, "转换成功!", values);
  690. return Ok(jw);
  691. }
  692. }
  693. }