BusinessController.cs 26 KB

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