BusinessController.cs 23 KB

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