ZhongTianKlhcController.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using AutoMapper;
  2. using CSRedis;
  3. using Microsoft.AspNetCore.Mvc;
  4. using Wms.Screen.Service.IService;
  5. using Wms.Screen.SqlSugar.ZhongTian.KLHC;
  6. namespace zt.screen.api.Controllers
  7. {
  8. /// <summary>
  9. /// 中天空轮缓存看板
  10. /// </summary>
  11. [Route("api/[controller]/[action]")]
  12. [ApiController]
  13. public class ZhongTianKlhcController : ControllerBase
  14. {
  15. private IZhongTianKlhcService _zhongTianKlhcService;
  16. private IMapper _mapper;
  17. private readonly CSRedisClient _CSRedisClient;
  18. private readonly FreeRedis.RedisClient _freeRedisClient;
  19. public ZhongTianKlhcController(IZhongTianKlhcService zhongTianKlhcService, IMapper mapper, CSRedisClient cSRedisClient, FreeRedis.RedisClient freeRedisClient)
  20. {
  21. _zhongTianKlhcService = zhongTianKlhcService;
  22. _mapper = mapper;
  23. _CSRedisClient = cSRedisClient;
  24. _freeRedisClient = freeRedisClient;
  25. }
  26. /// <summary>
  27. /// 获取缓存信息
  28. /// </summary>
  29. /// <returns></returns>
  30. [HttpPost]
  31. public List<BaseRBCI> GetRbci()
  32. {
  33. return _zhongTianKlhcService.GetBaseRrciList();
  34. }
  35. /// <summary>
  36. /// 获取库存信息
  37. /// </summary>
  38. /// <returns></returns>
  39. [HttpPost]
  40. public List<KlhcInvInfoResult> GetKlhcInvInfo()
  41. {
  42. var InvInfo = _zhongTianKlhcService.GetKlhcInvInfo();
  43. var info = InvInfo.First(x => x.WheelType == "总计");
  44. var InvInfos = InvInfo.Select(x => new KlhcInvInfoResult
  45. {
  46. WheelType = x.WheelType,
  47. Number = x.Number,
  48. Ratio = Math.Round(((x.Number / info.Number) * 100), 2),
  49. }).ToList();
  50. return InvInfos;
  51. }
  52. }
  53. // 定义明确的返回类型
  54. public class KlhcInvInfoResult
  55. {
  56. public string WheelType { get; set; }
  57. public decimal Number { get; set; }
  58. public decimal Ratio { get; set; }
  59. }
  60. }