BusinessController.cs 25 KB

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