BusinessController.cs 25 KB

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