BusinessController.cs 31 KB

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