BusinessController.cs 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812
  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) { _view.Insert(3, jdzc_view); _view1.Remove(jdzc_view); };
  126. SetDataInfoView cdy_view = new SetDataInfoView();//79 车/导游地接
  127. cdy_view = _view1.Where(it => it.Id == 79).FirstOrDefault();
  128. if (cdy_view != null) { _view.Insert(4, cdy_view); _view1.Remove(cdy_view); };
  129. SetDataInfoView yqgw_view = new SetDataInfoView();//81 邀请/公务活动
  130. yqgw_view = _view1.Where(it => it.Id == 81).FirstOrDefault();
  131. if (yqgw_view != null) { _view.Insert(5, yqgw_view); _view1.Remove(yqgw_view); };
  132. SetDataInfoView bx_view = new SetDataInfoView();//82 团组客户保险
  133. bx_view = _view1.Where(it => it.Id == 82).FirstOrDefault();
  134. if (bx_view != null) { _view.Insert(6, bx_view); _view1.Remove(bx_view); };
  135. SetDataInfoView qtkx_view = new SetDataInfoView();//98 其他款项
  136. qtkx_view = _view1.Where(it => it.Id == 98).FirstOrDefault();
  137. if (qtkx_view != null) { _view.Insert(7, qtkx_view); _view1.Remove(qtkx_view); };
  138. SetDataInfoView skth_view = new SetDataInfoView();//285 收款退还与其他款项
  139. skth_view = _view1.Where(it => it.Id == 285).FirstOrDefault();
  140. if (skth_view != null) { _view.Insert(8, skth_view); _view1.Remove(skth_view); };
  141. if (_view1.Count > 0)
  142. {
  143. _view.AddRange(_view1);
  144. }
  145. return Ok(JsonView(_view));
  146. }
  147. /// <summary>
  148. /// 查询团组简略详情列表
  149. /// Page 根据Ctable And User 返回可操作的团
  150. /// </summary>
  151. /// <param name="dto"></param>
  152. /// <returns></returns>
  153. [HttpPost]
  154. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  155. public async Task<IActionResult> PostGroupListByCTableAndUserId(GroupListByCTableAndUserIdDto dto)
  156. {
  157. if (dto.CTable < 1) Ok(JsonView(false, @"请输入正确的员工给Id!"));
  158. if (dto.CTable < 1)
  159. return Ok(JsonView(false, @"请输入正确的CTable Id !76 酒店预订 77 行程 79 车/导游地接<br/>80 签证 81 邀请/公务活动 82 团组客户保险<br\>85 机票预订 98 其他款项 751 酒店早餐"));
  160. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3)
  161. {
  162. string sql = string.Format(@"Select row_number() over(order by di.VisitStartDate Desc) as Row_Number,
  163. di.Id,di.TeamName,di.TourCode,di.ClientName,di.VisitCountry,di.VisitStartDate,
  164. di.VisitEndDate,di.VisitDays,di.VisitPNumber
  165. From Grp_GroupsTaskAssignment gta
  166. Inner Join Grp_DelegationInfo di On gta.DIId = di.Id
  167. Where gta.IsDel = 0 And di.IsDel = 0 And gta.IsEnable = 1
  168. And gta.CTId = {0} And gta.UId = {1}", dto.CTable, dto.UserId);
  169. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  170. var data = await _groupRep._sqlSugar.SqlQueryable<GroupListByCTableAndUserIdView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total); //ToPageAsync
  171. foreach (var item in data)
  172. {
  173. item.VisitStartDate = item.VisitStartDate == "" ? "" : Convert.ToDateTime(item.VisitStartDate).ToString("yyyy-MM-dd");
  174. item.VisitEndDate = item.VisitEndDate == "" ? "" : Convert.ToDateTime(item.VisitEndDate).ToString("yyyy-MM-dd");
  175. }
  176. return Ok(JsonView(true, "操作成功!", data, total));
  177. }
  178. else
  179. {
  180. return Ok(JsonView(false, @"请输入正确的PortType 1 Web 2 Android 3 IOS "));
  181. }
  182. }
  183. #endregion
  184. #region 币种 List
  185. /// <summary>
  186. /// 币种 List
  187. /// </summary>
  188. /// <returns></returns>
  189. [HttpGet,HttpPost]
  190. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  191. public async Task<IActionResult> PostCurrencyList()
  192. {
  193. try
  194. {
  195. Result setData = await _setDataRep.GetSetDataBySTId(_setDataRep, 66); //币种类型
  196. if (setData.Code == 0)
  197. {
  198. return Ok(JsonView(true, "查询成功", setData.Data));
  199. }
  200. else
  201. {
  202. return Ok(JsonView(false, setData.Msg));
  203. }
  204. }
  205. catch (Exception)
  206. {
  207. return Ok(JsonView(false, "程序错误!"));
  208. throw;
  209. }
  210. }
  211. /// <summary>
  212. /// 团组汇率 币种 Item (来源:团组汇率)
  213. /// 根据 团组Id And 业务类型(CTable)Id
  214. /// api处理CTable = 285,默认返回CNY
  215. /// </summary>
  216. /// <param name="dto"> 请求参数Dto </param>
  217. /// <returns></returns>
  218. [HttpPost]
  219. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  220. public async Task<IActionResult> PostGroupTeamRateByDiIdAndCTableId(GeneralTeamRateInfoDto dto)
  221. {
  222. try
  223. {
  224. if (dto == null)
  225. {
  226. return Ok(JsonView(false, "请输入参数!"));
  227. }
  228. if (dto.DiId == 0)
  229. {
  230. return Ok(JsonView(false, "请输入正确的团组Id!"));
  231. }
  232. if (dto.CTable == 0)
  233. {
  234. return Ok(JsonView(false, "请输入正确的业务类型(CTable)Id!"));
  235. }
  236. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3 )
  237. {
  238. string teamRateInfoSql = string.Format(@"Select sd.Name,tr.* From Grp_TeamRate tr
  239. Left Join Sys_SetData sd On sd.IsDel=0 And sd.STid=16 And tr.CTable = sd.Id
  240. Where tr.IsDel = 0 And tr.DiId = {0} And tr.CTable = {1}", dto.DiId,dto.CTable);
  241. var teamRateInfo = await _teamRateRep._sqlSugar.SqlQueryable<TeamRateInfoView>(teamRateInfoSql).ToListAsync();
  242. #region 团组汇率
  243. TeamRateModelGeneralView teamRateModels = new TeamRateModelGeneralView();
  244. #region 单独处理Ctable 币种汇率 默认 为CNY
  245. if (dto.CTable == 285)
  246. {
  247. teamRateModels = new TeamRateModelGeneralView()
  248. {
  249. Id = 0,
  250. CTableId = 285,
  251. CTableName = "其他款项与收款退还",
  252. TeamRates = new List<TeamRateDescAddCurrencyIdView>() {
  253. new TeamRateDescAddCurrencyIdView()
  254. {
  255. CurrencyId = 836,
  256. CurrencyCode = "CNY",
  257. CurrencyName = "人民币",
  258. Rate = 1.0000M,
  259. }
  260. }
  261. };
  262. return Ok(JsonView(true, "操作成功!", teamRateModels));
  263. }
  264. #endregion
  265. List<SetDataInfoView> currencyDatas = new List<SetDataInfoView>();
  266. #region 获取所有币种
  267. string sql = string.Format(@"select * from Sys_SetData where STid = {0} and isdel = 0", 66);
  268. var DBdata = await _setDataRep.GetListBySqlWithNolockAsync(sql);
  269. if (DBdata == null || DBdata.Count == 0)
  270. {
  271. return Ok(JsonView(false, "所有币种获取失败!"));
  272. }
  273. currencyDatas = DBdata.Select(x => new SetDataInfoView
  274. {
  275. Name = x.Name,
  276. Id = x.Id,
  277. Remark = x.Remark,
  278. }).ToList();
  279. #endregion
  280. foreach (TeamRateInfoView item in teamRateInfo)
  281. {
  282. TeamRateModelGeneralView teamRateModelInfo = new TeamRateModelGeneralView();
  283. teamRateModelInfo.Id = item.Id;
  284. teamRateModelInfo.CTableId = item.CTable;
  285. teamRateModelInfo.CTableName = item.Name;
  286. List<TeamRateDescAddCurrencyIdView> teamRateDescViews = new List<TeamRateDescAddCurrencyIdView>();
  287. #region 拆分remark里的汇率
  288. if (item.Remark.Contains("|"))
  289. {
  290. string[] currencyArr = item.Remark.Split("|");
  291. foreach (string currency in currencyArr)
  292. {
  293. string[] currency1 = currency.Split(":");
  294. string[] currency2 = currency1[0].Split("(");
  295. string currencyCode = currency2[1].Replace(")", "").TrimEnd();
  296. SetDataInfoView dataInfoView = new SetDataInfoView();
  297. dataInfoView = currencyDatas.Where(it => it.Name == currencyCode).FirstOrDefault();
  298. int currencyId = currencyDatas.Where(it => it.Name == currencyCode).FirstOrDefault().Id;
  299. TeamRateDescAddCurrencyIdView rateDescView = new TeamRateDescAddCurrencyIdView()
  300. {
  301. CurrencyId = dataInfoView.Id,
  302. CurrencyCode = currencyCode,
  303. CurrencyName = currency2[0],
  304. Rate = decimal.Parse(currency1[1]),
  305. };
  306. teamRateDescViews.Add(rateDescView);
  307. }
  308. }
  309. else
  310. {
  311. if (!string.IsNullOrEmpty(item.Remark))
  312. {
  313. string[] currency1 = item.Remark.Split(":");
  314. string[] currency2 = currency1[0].Split("(");
  315. string currencyCode = currency2[1].Replace(")", "").TrimEnd();
  316. SetDataInfoView dataInfoView = new SetDataInfoView();
  317. dataInfoView = currencyDatas.Where(it => it.Name == currencyCode).FirstOrDefault();
  318. int currencyId = currencyDatas.Where(it => it.Name == currencyCode).FirstOrDefault().Id;
  319. TeamRateDescAddCurrencyIdView rateDescView = new TeamRateDescAddCurrencyIdView()
  320. {
  321. CurrencyId = dataInfoView.Id,
  322. CurrencyCode = currencyCode,
  323. CurrencyName = currency2[0],
  324. Rate = decimal.Parse(currency1[1]),
  325. };
  326. teamRateDescViews.Add(rateDescView);
  327. }
  328. }
  329. #endregion
  330. if (teamRateDescViews.Count > 0)
  331. {
  332. teamRateDescViews = teamRateDescViews.OrderBy(it => it.CurrencyId).ToList();
  333. }
  334. teamRateModelInfo.TeamRates = teamRateDescViews;
  335. teamRateModels = teamRateModelInfo;
  336. }
  337. if (teamRateModels.TeamRates == null)
  338. {
  339. teamRateModels.TeamRates = new List<TeamRateDescAddCurrencyIdView>();
  340. }
  341. #endregion
  342. return Ok(JsonView(true, "操作成功!", teamRateModels));
  343. }
  344. else
  345. {
  346. return Ok(JsonView(false, "请输入正确的端口号! 1 Web 2 Android 3 Ios;"));
  347. }
  348. }
  349. catch (Exception ex)
  350. {
  351. return Ok(JsonView(false, ex.Message));
  352. }
  353. }
  354. /// <summary>
  355. /// 根据团组Id币种Id及类型Id查询团组汇率
  356. /// </summary>
  357. /// <param name="dto"></param>
  358. /// <returns></returns>
  359. [HttpGet, HttpPost]
  360. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  361. public async Task<IActionResult> PostCurrencyByDiid(int DiId,int CId,int CurrencyId)
  362. {
  363. try
  364. {
  365. Result setData = await _setDataRep.PostCurrencyByDiid( DiId, CId, CurrencyId); //币种类型
  366. if (setData.Code == 0)
  367. {
  368. return Ok(JsonView(true, "查询成功", setData.Data));
  369. }
  370. else
  371. {
  372. return Ok(JsonView(false, setData.Msg));
  373. }
  374. }
  375. catch (Exception)
  376. {
  377. return Ok(JsonView(false, "程序错误!"));
  378. throw;
  379. }
  380. }
  381. #endregion
  382. #region 查询页面关联Ctable
  383. /// <summary>
  384. /// 页面关联Ctable
  385. /// 根据PageId 返回 CTable Id
  386. /// </summary>
  387. /// <param name="dto"></param>
  388. /// <returns></returns>
  389. [HttpPost]
  390. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  391. public async Task<IActionResult> PostPageLinkCTable(PageLinkCTableDto dto)
  392. {
  393. try
  394. {
  395. if (dto == null)
  396. {
  397. return Ok(JsonView(false, "请求参数不能为空!"));
  398. }
  399. if (dto.PageId == 0)
  400. {
  401. return Ok(JsonView(false, "页面Id不能为0!"));
  402. }
  403. List<CTableCorrelationPageDatas> data = AppSettingsHelper.Get<CTableCorrelationPageDatas>("CTableCorrelationPageDatas");
  404. CTableCorrelationPageDatas correlationPageDatas = new CTableCorrelationPageDatas();
  405. foreach (var item in data)
  406. {
  407. if (item.PageIdDatas != null)
  408. {
  409. var pageId = item.PageIdDatas.Where(it => it == dto.PageId).FirstOrDefault();
  410. if (pageId != 0)
  411. {
  412. correlationPageDatas = item;
  413. break;
  414. }
  415. }
  416. }
  417. if (correlationPageDatas.CTableId == 0)
  418. {
  419. return Ok(JsonView(false, "您查询的页面Id,未配置AppSettings,请前往配置!"));
  420. }
  421. return Ok(JsonView(true, "操作成功",new { CTable = correlationPageDatas.CTableId }));
  422. }
  423. catch (Exception ex)
  424. {
  425. return Ok(JsonView(false, ex.Message));
  426. }
  427. }
  428. #endregion
  429. #region 会务物料单
  430. /// <summary>
  431. /// 获取会务活动列表
  432. /// </summary>
  433. /// <param name="paras"></param>
  434. /// <returns></returns>
  435. [HttpPost]
  436. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  437. public async Task<IActionResult> PostConferenceList()
  438. {
  439. List<Grp_DelegationInfo> listSource = _busRep.Query<Grp_DelegationInfo>(s => s.TeamDid == 691 && s.IsDel == 0).ToList();
  440. List<GroupNameView> viewList = new List<GroupNameView>();
  441. foreach (var group in listSource)
  442. {
  443. GroupNameView _view = new GroupNameView();
  444. _view.Id = group.Id;
  445. _view.GroupName = group.TeamName;
  446. }
  447. return Ok(JsonView(viewList));
  448. }
  449. /// <summary>
  450. /// 获取会务的采购物品计划清单
  451. /// </summary>
  452. /// <param name="ConfId">会务活动Id</param>
  453. /// <returns></returns>
  454. [HttpPost]
  455. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  456. public async Task<IActionResult> PostConfItemList(int ConfId)
  457. {
  458. Bus_ConfItemListView view = new Bus_ConfItemListView();
  459. Bus_ConfItemListInfo _confListInfo = await _busRep.Query<Bus_ConfItemListInfo>(s => s.Diid == ConfId).FirstAsync();
  460. if (_confListInfo != null)
  461. {
  462. view.TotalCost = _confListInfo.TotalCost;
  463. string sqlItem = string.Format(@" Select c.Id,c.ItemId,d.ItemName,c.[Count],c.CurrCost,c.OpRemark
  464. From Bus_ConfItem as c With(Nolock)
  465. Inner Join Res_ItemDetail as d with(Nolock) On c.ItemId=d.Id
  466. Where c.ConfListId = {0}", ConfId);
  467. List<Bus_ConfItemView> confItemList = await _busRep._sqlSugar.SqlQueryable<Bus_ConfItemView>(sqlItem).ToListAsync();
  468. view.ItemList = new List<Bus_ConfItemView>(confItemList);
  469. }
  470. else
  471. {
  472. view.ItemList = new List<Bus_ConfItemView>();
  473. view.TotalCost = 0;
  474. }
  475. return Ok(JsonView(view));
  476. }
  477. /// <summary>
  478. /// 获取会务可采购的物料集合
  479. /// </summary>
  480. /// <returns></returns>
  481. [HttpPost]
  482. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  483. public async Task<IActionResult> PostOptionalItemList()
  484. {
  485. List<OptionalBusRangeView> result = await _busRep.GetViewList_OptionalItem();
  486. return Ok(JsonView(result));
  487. }
  488. /// <summary>
  489. /// 编辑物料采购清单
  490. /// </summary>
  491. /// <returns></returns>
  492. [HttpPost]
  493. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  494. public async Task<IActionResult> PostEditOptionalItemList(JsonDtoBase jsonDto)
  495. {
  496. if (string.IsNullOrEmpty(jsonDto.Paras))
  497. {
  498. return Ok(JsonView(false, "参数为空"));
  499. }
  500. Edit_OptionalItemListDto _dto = JsonConvert.DeserializeObject<Edit_OptionalItemListDto>(jsonDto.Paras);
  501. //Edit_OptionalItemListDto _dto = System.Text.Json.JsonSerializer.Deserialize<Edit_OptionalItemListDto>(jsonDto.Paras);
  502. if (_dto.DiId < 1)
  503. {
  504. return Ok(JsonView(false, "团组Id为空"));
  505. }
  506. if (_dto.ConfItemListId < 1)
  507. {
  508. //新增
  509. int rstInsert = await _busRep.Insert_ConfItemList(_dto);
  510. return Ok(JsonView(rstInsert == 0));
  511. }
  512. else
  513. {
  514. //修改
  515. int rstUpdate = await _busRep.Edit_ConfItemList(_dto);
  516. return Ok(JsonView(rstUpdate == 0));
  517. }
  518. return Ok(JsonView(false));
  519. }
  520. /// <summary>
  521. /// 获取会务采购物料清单Excel
  522. /// </summary>
  523. /// <returns></returns>
  524. [HttpPost]
  525. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  526. public async Task<IActionResult> Excel_ConfItemList(JsonDtoBase jsonDto)
  527. {
  528. if (string.IsNullOrEmpty(jsonDto.Paras))
  529. {
  530. return Ok(JsonView(false, "参数为空"));
  531. }
  532. dynamic confList = JsonConvert.DeserializeObject<dynamic>(jsonDto.Paras);
  533. int confListId = confList.ConfListId;
  534. Bus_ConfItemListInfo _entityConfList = await _busRep.Query<Bus_ConfItemListInfo>(s => s.Id == confListId).FirstAsync();
  535. if (_entityConfList != null)
  536. {
  537. string result = new Excel_BusConfItemList().Excel(_entityConfList);
  538. }
  539. else
  540. {
  541. return Ok(JsonView(false, "请先保存数据"));
  542. }
  543. return Ok(JsonView(false));
  544. }
  545. #endregion
  546. #region 阿里云短信测试
  547. /// <summary>
  548. /// 编辑物料采购清单
  549. /// </summary>
  550. /// <returns></returns>
  551. [HttpPost]
  552. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  553. public async Task<IActionResult> AliMessageTest(string mobile)
  554. {
  555. string add2dayZH = DateTime.Now.AddDays(2).ToString("yyyy年MM月dd日");
  556. string templateParam = JsonConvert.SerializeObject(new { teams = "测试团组", date = add2dayZH });
  557. AliMessagePost.PostMessage(mobile, "泛美国际团组", "SMS_461575447", templateParam);
  558. return Ok(JsonView(true));
  559. }
  560. #endregion
  561. #region 文件删除
  562. /// <summary>
  563. /// 文件操作
  564. /// 删除指定文件
  565. /// </summary>
  566. /// <param name="dto">Dto</param>
  567. /// <returns></returns>
  568. [HttpPost]
  569. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  570. public async Task<IActionResult> PostFileDel(FileDelDto dto)
  571. {
  572. try
  573. {
  574. string pathUrl = dto.PathUrl;
  575. if (string.IsNullOrEmpty(pathUrl))
  576. return Ok(JsonView(false, "路径为空或者不是有效路径!"));
  577. if (System.IO.File.Exists(pathUrl))
  578. {
  579. System.IO.File.Delete(pathUrl);
  580. return Ok(JsonView(false, "操作成功!"));
  581. }
  582. else
  583. {
  584. return Ok(JsonView(false, "该文件不存在!"));
  585. }
  586. }
  587. catch (Exception ex)
  588. {
  589. return Ok(JsonView(false, ex.Message));
  590. }
  591. }
  592. #endregion
  593. #region 表操作记录
  594. /// <summary>
  595. /// 表操作记录
  596. /// 添加
  597. /// </summary>
  598. /// <returns></returns>
  599. [HttpPost]
  600. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  601. public async Task<IActionResult> PostTableOperationRecordAdd(TableOperationRecordAddDto _dto )
  602. {
  603. try
  604. {
  605. Crm_TableOperationRecord _TableOperationRecord = new Crm_TableOperationRecord()
  606. {
  607. TableName = _dto.TableName,
  608. PortType = _dto.PortType,
  609. OperationItem = _dto.OperationItem,
  610. DataId = _dto.DataId,
  611. CreateUserId = _dto.UserId,
  612. CreateTime = DateTime.Now,
  613. Remark = "",
  614. IsDel = 0
  615. };
  616. bool _view = await _TableOperationRecordRep._Add(_TableOperationRecord);
  617. if (_view)
  618. {
  619. return Ok(JsonView(true,"操作成功!"));
  620. }
  621. else
  622. {
  623. return Ok(JsonView(false,"操作失败!"));
  624. }
  625. }
  626. catch (Exception)
  627. {
  628. return Ok(JsonView(false, "程序错误!"));
  629. }
  630. }
  631. /// <summary>
  632. /// 表操作记录
  633. /// 分页
  634. /// </summary>
  635. /// <returns></returns>
  636. [HttpPost]
  637. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  638. public async Task<IActionResult> PostTableOperationRecordPageList(TableOperationRecordPageDto _dto)
  639. {
  640. try
  641. {
  642. string whereSql = "";
  643. if (!string.IsNullOrEmpty(_dto.TableName))
  644. {
  645. whereSql = string.Format(" And tor.TableName = '{0}'", _dto.TableName);
  646. }
  647. string sql = string.Format(@"Select row_number() over(order by tor.CreateTime Desc) As Row_Number,
  648. tor.TableName,tor.PortType,tor.OperationItem,tor.DataId,u.CnName As OperationUserName,
  649. tor.CreateTime,tor.Remark
  650. From Crm_TableOperationRecord tor
  651. Left Join Sys_Users u On tor.CreateUserId = u.Id
  652. Where tor.Isdel = 0 {0}", whereSql);
  653. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  654. var _view = await _TableOperationRecordRep._sqlSugar.SqlQueryable<TableOperationRecordPageView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  655. return Ok(JsonView(true, "查询成功!", _view, total));
  656. }
  657. catch (Exception ex)
  658. {
  659. return Ok(JsonView(false, "程序错误!Msg:" + ex.Message));
  660. }
  661. }
  662. #endregion
  663. /// <summary>
  664. /// 汉字转拼音
  665. /// </summary>
  666. /// <param name="dto"></param>
  667. /// <returns></returns>
  668. [HttpPost]
  669. public IActionResult ChineseToEnFn(ChineseToEn dto)
  670. {
  671. var jw = JsonView(false, "请输入中文!");
  672. if (dto.originalText.Count == 0)
  673. {
  674. return Ok(jw);
  675. }
  676. List<string> values = new List<string>();
  677. foreach (var item in dto.originalText)
  678. {
  679. var val = item.GetTotalPingYin();
  680. if (dto.isUp)
  681. {
  682. val = val.Select(x => x.ToUpper()).ToList();
  683. }
  684. values.Add(val.Count > 0 ? val[0]: "暂无该拼音!");
  685. }
  686. jw = JsonView(true, "转换成功!", values);
  687. return Ok(jw);
  688. }
  689. }
  690. }