BusinessController.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  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.CreateTime Desc) as Row_Number,
  166. di.Id,di.TeamName,di.TourCode,di.ClientName,di.VisitCountry,di.VisitStartDate,
  167. di.VisitEndDate,di.VisitDays,di.VisitPNumber,di.CreateTime
  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. if (!string.IsNullOrEmpty(dto.TeamName))
  173. {
  174. sql = string.Format($"{sql} And di.TeamName Like '%{dto.TeamName}%'");
  175. }
  176. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  177. var data = await _groupRep._sqlSugar.SqlQueryable<GroupListByCTableAndUserIdView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total); //ToPageAsync
  178. foreach (var item in data)
  179. {
  180. item.VisitStartDate = item.VisitStartDate == "" ? "" : Convert.ToDateTime(item.VisitStartDate).ToString("yyyy-MM-dd");
  181. item.VisitEndDate = item.VisitEndDate == "" ? "" : Convert.ToDateTime(item.VisitEndDate).ToString("yyyy-MM-dd");
  182. }
  183. return Ok(JsonView(true, "操作成功!", data, total));
  184. }
  185. else
  186. {
  187. return Ok(JsonView(false, @"请输入正确的PortType 1 Web 2 Android 3 IOS "));
  188. }
  189. }
  190. #endregion
  191. #region 币种 List
  192. /// <summary>
  193. /// 币种 List
  194. /// </summary>
  195. /// <returns></returns>
  196. [HttpGet,HttpPost]
  197. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  198. public async Task<IActionResult> PostCurrencyList()
  199. {
  200. try
  201. {
  202. Result setData = await _setDataRep.GetSetDataBySTId(_setDataRep, 66); //币种类型
  203. if (setData.Code == 0)
  204. {
  205. return Ok(JsonView(true, "查询成功", setData.Data));
  206. }
  207. else
  208. {
  209. return Ok(JsonView(false, setData.Msg));
  210. }
  211. }
  212. catch (Exception)
  213. {
  214. return Ok(JsonView(false, "程序错误!"));
  215. throw;
  216. }
  217. }
  218. /// <summary>
  219. /// 团组汇率 币种 Item (来源:团组汇率)
  220. /// 根据 团组Id And 业务类型(CTable)Id
  221. /// api处理CTable = 285,默认返回CNY
  222. /// </summary>
  223. /// <param name="dto"> 请求参数Dto </param>
  224. /// <returns></returns>
  225. [HttpPost]
  226. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  227. public async Task<IActionResult> PostGroupTeamRateByDiIdAndCTableId(GeneralTeamRateInfoDto dto)
  228. {
  229. try
  230. {
  231. if (dto == null)
  232. {
  233. return Ok(JsonView(false, "请输入参数!"));
  234. }
  235. if (dto.DiId == 0)
  236. {
  237. return Ok(JsonView(false, "请输入正确的团组Id!"));
  238. }
  239. if (dto.CTable == 0)
  240. {
  241. return Ok(JsonView(false, "请输入正确的业务类型(CTable)Id!"));
  242. }
  243. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3 )
  244. {
  245. var _vew = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType,dto.DiId,dto.CTable);
  246. return Ok(JsonView(true, "操作成功!", _vew));
  247. }
  248. else
  249. {
  250. return Ok(JsonView(false, "请输入正确的端口号! 1 Web 2 Android 3 Ios;"));
  251. }
  252. }
  253. catch (Exception ex)
  254. {
  255. return Ok(JsonView(false, ex.Message));
  256. }
  257. }
  258. /// <summary>
  259. /// 根据团组Id币种Id及类型Id查询团组汇率
  260. /// </summary>
  261. /// <param name="dto"></param>
  262. /// <returns></returns>
  263. [HttpGet, HttpPost]
  264. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  265. public async Task<IActionResult> PostCurrencyByDiid(int DiId,int CId,int CurrencyId)
  266. {
  267. try
  268. {
  269. Result setData = await _setDataRep.PostCurrencyByDiid( DiId, CId, CurrencyId); //币种类型
  270. if (setData.Code == 0)
  271. {
  272. return Ok(JsonView(true, "查询成功", setData.Data));
  273. }
  274. else
  275. {
  276. return Ok(JsonView(false, setData.Msg));
  277. }
  278. }
  279. catch (Exception)
  280. {
  281. return Ok(JsonView(false, "程序错误!"));
  282. throw;
  283. }
  284. }
  285. #endregion
  286. #region 查询页面关联Ctable
  287. /// <summary>
  288. /// 页面关联Ctable
  289. /// 根据PageId 返回 CTable Id
  290. /// </summary>
  291. /// <param name="dto"></param>
  292. /// <returns></returns>
  293. [HttpPost]
  294. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  295. public async Task<IActionResult> PostPageLinkCTable(PageLinkCTableDto dto)
  296. {
  297. try
  298. {
  299. if (dto == null)
  300. {
  301. return Ok(JsonView(false, "请求参数不能为空!"));
  302. }
  303. if (dto.PageId == 0)
  304. {
  305. return Ok(JsonView(false, "页面Id不能为0!"));
  306. }
  307. List<CTableCorrelationPageDatas> data = AppSettingsHelper.Get<CTableCorrelationPageDatas>("CTableCorrelationPageDatas");
  308. CTableCorrelationPageDatas correlationPageDatas = new CTableCorrelationPageDatas();
  309. foreach (var item in data)
  310. {
  311. if (item.PageIdDatas != null)
  312. {
  313. var pageId = item.PageIdDatas.Where(it => it == dto.PageId).FirstOrDefault();
  314. if (pageId != 0)
  315. {
  316. correlationPageDatas = item;
  317. break;
  318. }
  319. }
  320. }
  321. if (correlationPageDatas.CTableId == 0)
  322. {
  323. return Ok(JsonView(false, "您查询的页面Id,未配置AppSettings,请前往配置!"));
  324. }
  325. return Ok(JsonView(true, "操作成功",new { CTable = correlationPageDatas.CTableId }));
  326. }
  327. catch (Exception ex)
  328. {
  329. return Ok(JsonView(false, ex.Message));
  330. }
  331. }
  332. #endregion
  333. #region 会务物料单
  334. /// <summary>
  335. /// 获取会务活动列表
  336. /// </summary>
  337. /// <param name="paras"></param>
  338. /// <returns></returns>
  339. [HttpPost]
  340. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  341. public async Task<IActionResult> PostConferenceList()
  342. {
  343. List<Grp_DelegationInfo> listSource = _busRep.Query<Grp_DelegationInfo>(s => s.TeamDid == 691 && s.IsDel == 0).ToList();
  344. List<GroupNameView> viewList = new List<GroupNameView>();
  345. foreach (var group in listSource)
  346. {
  347. GroupNameView _view = new GroupNameView();
  348. _view.Id = group.Id;
  349. _view.GroupName = group.TeamName;
  350. }
  351. return Ok(JsonView(viewList));
  352. }
  353. /// <summary>
  354. /// 获取会务的采购物品计划清单
  355. /// </summary>
  356. /// <param name="ConfId">会务活动Id</param>
  357. /// <returns></returns>
  358. [HttpPost]
  359. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  360. public async Task<IActionResult> PostConfItemList(int ConfId)
  361. {
  362. Bus_ConfItemListView view = new Bus_ConfItemListView();
  363. Bus_ConfItemListInfo _confListInfo = await _busRep.Query<Bus_ConfItemListInfo>(s => s.Diid == ConfId).FirstAsync();
  364. if (_confListInfo != null)
  365. {
  366. view.TotalCost = _confListInfo.TotalCost;
  367. string sqlItem = string.Format(@" Select c.Id,c.ItemId,d.ItemName,c.[Count],c.CurrCost,c.OpRemark
  368. From Bus_ConfItem as c With(Nolock)
  369. Inner Join Res_ItemDetail as d with(Nolock) On c.ItemId=d.Id
  370. Where c.ConfListId = {0}", ConfId);
  371. List<Bus_ConfItemView> confItemList = await _busRep._sqlSugar.SqlQueryable<Bus_ConfItemView>(sqlItem).ToListAsync();
  372. view.ItemList = new List<Bus_ConfItemView>(confItemList);
  373. }
  374. else
  375. {
  376. view.ItemList = new List<Bus_ConfItemView>();
  377. view.TotalCost = 0;
  378. }
  379. return Ok(JsonView(view));
  380. }
  381. /// <summary>
  382. /// 获取会务可采购的物料集合
  383. /// </summary>
  384. /// <returns></returns>
  385. [HttpPost]
  386. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  387. public async Task<IActionResult> PostOptionalItemList()
  388. {
  389. List<OptionalBusRangeView> result = await _busRep.GetViewList_OptionalItem();
  390. return Ok(JsonView(result));
  391. }
  392. /// <summary>
  393. /// 编辑物料采购清单
  394. /// </summary>
  395. /// <returns></returns>
  396. [HttpPost]
  397. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  398. public async Task<IActionResult> PostEditOptionalItemList(JsonDtoBase jsonDto)
  399. {
  400. if (string.IsNullOrEmpty(jsonDto.Paras))
  401. {
  402. return Ok(JsonView(false, "参数为空"));
  403. }
  404. Edit_OptionalItemListDto _dto = JsonConvert.DeserializeObject<Edit_OptionalItemListDto>(jsonDto.Paras);
  405. //Edit_OptionalItemListDto _dto = System.Text.Json.JsonSerializer.Deserialize<Edit_OptionalItemListDto>(jsonDto.Paras);
  406. if (_dto.DiId < 1)
  407. {
  408. return Ok(JsonView(false, "团组Id为空"));
  409. }
  410. if (_dto.ConfItemListId < 1)
  411. {
  412. //新增
  413. int rstInsert = await _busRep.Insert_ConfItemList(_dto);
  414. return Ok(JsonView(rstInsert == 0));
  415. }
  416. else
  417. {
  418. //修改
  419. int rstUpdate = await _busRep.Edit_ConfItemList(_dto);
  420. return Ok(JsonView(rstUpdate == 0));
  421. }
  422. return Ok(JsonView(false));
  423. }
  424. /// <summary>
  425. /// 获取会务采购物料清单Excel
  426. /// </summary>
  427. /// <returns></returns>
  428. [HttpPost]
  429. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  430. public async Task<IActionResult> Excel_ConfItemList(JsonDtoBase jsonDto)
  431. {
  432. if (string.IsNullOrEmpty(jsonDto.Paras))
  433. {
  434. return Ok(JsonView(false, "参数为空"));
  435. }
  436. dynamic confList = JsonConvert.DeserializeObject<dynamic>(jsonDto.Paras);
  437. int confListId = confList.ConfListId;
  438. Bus_ConfItemListInfo _entityConfList = await _busRep.Query<Bus_ConfItemListInfo>(s => s.Id == confListId).FirstAsync();
  439. if (_entityConfList != null)
  440. {
  441. string result = new Excel_BusConfItemList().Excel(_entityConfList);
  442. }
  443. else
  444. {
  445. return Ok(JsonView(false, "请先保存数据"));
  446. }
  447. return Ok(JsonView(false));
  448. }
  449. #endregion
  450. #region 阿里云短信测试
  451. /// <summary>
  452. /// 编辑物料采购清单
  453. /// </summary>
  454. /// <returns></returns>
  455. [HttpPost]
  456. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  457. public async Task<IActionResult> AliMessageTest(string mobile)
  458. {
  459. string add2dayZH = DateTime.Now.AddDays(2).ToString("yyyy年MM月dd日");
  460. string templateParam = JsonConvert.SerializeObject(new { teams = "测试团组", date = add2dayZH });
  461. AliMessagePost.PostMessage(mobile, "泛美国际团组", "SMS_461575447", templateParam);
  462. return Ok(JsonView(true));
  463. }
  464. #endregion
  465. #region 文件删除
  466. /// <summary>
  467. /// 文件操作
  468. /// 删除指定文件
  469. /// </summary>
  470. /// <param name="dto">Dto</param>
  471. /// <returns></returns>
  472. [HttpPost]
  473. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  474. public async Task<IActionResult> PostFileDel(FileDelDto dto)
  475. {
  476. try
  477. {
  478. string pathUrl = dto.PathUrl;
  479. if (string.IsNullOrEmpty(pathUrl))
  480. return Ok(JsonView(false, "路径为空或者不是有效路径!"));
  481. if (System.IO.File.Exists(pathUrl))
  482. {
  483. System.IO.File.Delete(pathUrl);
  484. return Ok(JsonView(false, "操作成功!"));
  485. }
  486. else
  487. {
  488. return Ok(JsonView(false, "该文件不存在!"));
  489. }
  490. }
  491. catch (Exception ex)
  492. {
  493. return Ok(JsonView(false, ex.Message));
  494. }
  495. }
  496. #endregion
  497. #region 表操作记录
  498. /// <summary>
  499. /// 表操作记录
  500. /// 添加
  501. /// </summary>
  502. /// <returns></returns>
  503. [HttpPost]
  504. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  505. public async Task<IActionResult> PostTableOperationRecordAdd(TableOperationRecordAddDto _dto )
  506. {
  507. try
  508. {
  509. Crm_TableOperationRecord _TableOperationRecord = new Crm_TableOperationRecord()
  510. {
  511. TableName = _dto.TableName,
  512. PortType = _dto.PortType,
  513. OperationItem = _dto.OperationItem,
  514. DataId = _dto.DataId,
  515. CreateUserId = _dto.UserId,
  516. CreateTime = DateTime.Now,
  517. Remark = "",
  518. IsDel = 0
  519. };
  520. bool _view = await _TableOperationRecordRep._Add(_TableOperationRecord);
  521. if (_view)
  522. {
  523. return Ok(JsonView(true,"操作成功!"));
  524. }
  525. else
  526. {
  527. return Ok(JsonView(false,"操作失败!"));
  528. }
  529. }
  530. catch (Exception)
  531. {
  532. return Ok(JsonView(false, "程序错误!"));
  533. }
  534. }
  535. /// <summary>
  536. /// 表操作记录
  537. /// 分页
  538. /// </summary>
  539. /// <returns></returns>
  540. [HttpPost]
  541. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  542. public async Task<IActionResult> PostTableOperationRecordPageList(TableOperationRecordPageDto _dto)
  543. {
  544. try
  545. {
  546. string whereSql = "";
  547. if (!string.IsNullOrEmpty(_dto.TableName))
  548. {
  549. whereSql = string.Format(" And tor.TableName = '{0}'", _dto.TableName);
  550. }
  551. string sql = string.Format(@"Select row_number() over(order by tor.CreateTime Desc) As Row_Number,
  552. tor.TableName,tor.PortType,tor.OperationItem,tor.DataId,u.CnName As OperationUserName,
  553. tor.CreateTime,tor.Remark
  554. From Crm_TableOperationRecord tor
  555. Left Join Sys_Users u On tor.CreateUserId = u.Id
  556. Where tor.Isdel = 0 {0}", whereSql);
  557. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  558. var _view = await _TableOperationRecordRep._sqlSugar.SqlQueryable<TableOperationRecordPageView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  559. return Ok(JsonView(true, "查询成功!", _view, total));
  560. }
  561. catch (Exception ex)
  562. {
  563. return Ok(JsonView(false, "程序错误!Msg:" + ex.Message));
  564. }
  565. }
  566. #endregion
  567. /// <summary>
  568. /// 汉字转拼音
  569. /// </summary>
  570. /// <param name="dto"></param>
  571. /// <returns></returns>
  572. [HttpPost]
  573. public IActionResult ChineseToEnFn(ChineseToEn dto)
  574. {
  575. var jw = JsonView(false, "请输入中文!");
  576. if (dto.originalText.Count == 0)
  577. {
  578. return Ok(jw);
  579. }
  580. List<string> values = new List<string>();
  581. foreach (var item in dto.originalText)
  582. {
  583. var val = item.GetTotalPingYin();
  584. if (dto.isUp)
  585. {
  586. val = val.Select(x => x.ToUpper()).ToList();
  587. }
  588. values.Add(val.Count > 0 ? val[0]: "暂无该拼音!");
  589. }
  590. jw = JsonView(true, "转换成功!", values);
  591. return Ok(jw);
  592. }
  593. }
  594. }