TopologicalEnterpriseWdController.java 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package com.ruoyi.demo.controller;
  2. import com.ruoyi.common.core.domain.R;
  3. import com.ruoyi.demo.constant.RedisContant;
  4. import com.ruoyi.demo.entity.TopologicalEnterpriseWd;
  5. import com.ruoyi.demo.entity.vo.TopologicalWdAceeptVo;
  6. import com.ruoyi.demo.service.TopologicalEnterpriseWdService;
  7. import com.ruoyi.demo.valida.TopologicalWdListGroup;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.data.redis.core.RedisTemplate;
  10. import org.springframework.validation.annotation.Validated;
  11. import org.springframework.web.bind.annotation.GetMapping;
  12. import org.springframework.web.bind.annotation.PostMapping;
  13. import org.springframework.web.bind.annotation.RequestMapping;
  14. import org.springframework.web.bind.annotation.RestController;
  15. import java.util.HashMap;
  16. import java.util.List;
  17. import java.util.concurrent.TimeUnit;
  18. /**
  19. * 点位评估:周边企业
  20. */
  21. @RestController
  22. @RequestMapping("/poi/topologicalEnterpriseWd")
  23. public class TopologicalEnterpriseWdController {
  24. @Autowired
  25. TopologicalEnterpriseWdService topologicalEnterpriseWdService;
  26. @Autowired
  27. RedisTemplate redisTemplate;
  28. /**
  29. * 获取周边企业网点列表
  30. * @param topologicalWdAceeptVo
  31. * @return
  32. */
  33. @GetMapping("/list")
  34. public R list(@Validated(value = {TopologicalWdListGroup.class}) TopologicalWdAceeptVo topologicalWdAceeptVo){
  35. String md5 = topologicalWdAceeptVo.getHash();
  36. //2.查看redis中是否存在有缓存
  37. HashMap<String,Object> wdCount = (HashMap<String,Object>) redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_ENTERPRISE_WD_LIST).get(md5);
  38. if (wdCount != null) {
  39. return R.ok(wdCount);
  40. }
  41. HashMap<String,Object> list = topologicalEnterpriseWdService.list(topologicalWdAceeptVo);
  42. redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_ENTERPRISE_WD_LIST).put(md5,list);
  43. redisTemplate.expire(RedisContant.TOPOLOGICAL_ENTERPRISE_WD_LIST,RedisContant.TOPOLOGICAL_ENTERPRISE_WD_LIST_TIME, TimeUnit.MINUTES); //30分钟
  44. return R.ok(list);
  45. }
  46. @GetMapping("/logisticsList")
  47. public R logisticsList(@Validated(value = {TopologicalWdListGroup.class}) TopologicalWdAceeptVo topologicalWdAceeptVo){
  48. String md5 = topologicalWdAceeptVo.getHash();
  49. //2.查看redis中是否存在有缓存
  50. HashMap<String,Object> wdCount = (HashMap<String,Object>) redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_ENTERPRISE_WD_LOGISTICS_LIST).get(md5);
  51. if (wdCount != null) {
  52. return R.ok(wdCount);
  53. }
  54. HashMap<String,Object> list = topologicalEnterpriseWdService.logisticsList(topologicalWdAceeptVo);
  55. redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_ENTERPRISE_WD_LOGISTICS_LIST).put(md5,list);
  56. redisTemplate.expire(RedisContant.TOPOLOGICAL_ENTERPRISE_WD_LOGISTICS_LIST,RedisContant.TOPOLOGICAL_ENTERPRISE_WD_LOGISTICS_LIST_TIME, TimeUnit.MINUTES);
  57. return R.ok(list);
  58. }
  59. }