WzHouseCustomerController.java 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. package com.example.controller.gdc;
  2. import com.example.config.annotation.IgnoreAuth;
  3. import com.example.pojo.gdc.OtnAreaEntity;
  4. import com.example.pojo.gdc.WzHouseCustomerEntity;
  5. import com.example.service.gdc.WzHouseCustomerService;
  6. import com.example.service.gdc.WzOtnAreaService;
  7. import com.example.utils.PageMap;
  8. import com.example.utils.PageUtils;
  9. import com.example.utils.Query;
  10. import com.example.utils.R;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.web.bind.annotation.RequestBody;
  13. import org.springframework.web.bind.annotation.RequestMapping;
  14. import org.springframework.web.bind.annotation.RestController;
  15. import java.util.ArrayList;
  16. import java.util.HashMap;
  17. import java.util.List;
  18. import java.util.Map;
  19. /**
  20. * 房屋出租(合同管理)
  21. */
  22. @RestController
  23. @RequestMapping("/house-car/house/dist/api/wzHouseCustomer")
  24. public class WzHouseCustomerController {
  25. @Autowired
  26. private WzHouseCustomerService wzHouseCustomerService;
  27. @Autowired
  28. private WzOtnAreaService otnAreaService;
  29. @RequestMapping("/list")
  30. @IgnoreAuth
  31. public R list(@RequestBody PageMap pageMap) {
  32. //查询列表数据
  33. Query query = new Query(pageMap);
  34. List<WzHouseCustomerEntity> list = wzHouseCustomerService.queryList(query);
  35. int total = wzHouseCustomerService.queryTotal(query);
  36. PageUtils pageUtil = new PageUtils(list, total, query.getLimit(), query.getPage());
  37. return R.ok().put("page", pageUtil);
  38. }
  39. @RequestMapping("/echartList")
  40. @IgnoreAuth
  41. public R echartList(@RequestBody PageMap pageMap) {
  42. //查询列表数据
  43. Query query = new Query(pageMap);
  44. List<WzHouseCustomerEntity> wzHouseContracEntityList = wzHouseCustomerService.queryList(query);
  45. WzHouseCustomerEntity province=new WzHouseCustomerEntity();
  46. province.setCity("全省");
  47. Map<String,List<WzHouseCustomerEntity>> map=new HashMap<>();
  48. for (WzHouseCustomerEntity leaveUseVo : wzHouseContracEntityList) {
  49. List<WzHouseCustomerEntity> list;
  50. if(map.get(leaveUseVo.getCity())!=null){
  51. list=map.get(leaveUseVo.getCity());
  52. list.add(leaveUseVo);
  53. }else{
  54. list=new ArrayList<>();
  55. list.add(leaveUseVo);
  56. }
  57. map.put(leaveUseVo.getCity(),list);
  58. }
  59. List<WzHouseCustomerEntity> resultList=new ArrayList<>();
  60. List<WzHouseCustomerEntity> cityList=new ArrayList<>();
  61. Integer allPerson=0;
  62. Integer allPersonPrivate=0;
  63. Integer allStateOwnedEnterprises=0;
  64. Integer allGovernment=0;
  65. Integer allAllNum=0;
  66. for(Map.Entry<String,List<WzHouseCustomerEntity>> entry:map.entrySet()){
  67. List<WzHouseCustomerEntity> list=entry.getValue();
  68. if(list.get(0).getCity().equals("全省")){
  69. continue;
  70. }
  71. Integer person=0;
  72. Integer personPrivate=0;
  73. Integer stateOwnedEnterprises=0;
  74. Integer government=0;
  75. Integer allNum=0;
  76. for (WzHouseCustomerEntity leaveUseVo : list) {
  77. if(leaveUseVo.getPerson()!=null){
  78. person+=leaveUseVo.getPerson();
  79. allPerson+=leaveUseVo.getPerson();
  80. }
  81. if(leaveUseVo.getPersonPrivate()!=null){
  82. personPrivate+=leaveUseVo.getPersonPrivate();
  83. allPersonPrivate+=leaveUseVo.getPersonPrivate();
  84. }
  85. if(leaveUseVo.getStateOwnedEnterprises()!=null){
  86. stateOwnedEnterprises+=leaveUseVo.getStateOwnedEnterprises();
  87. allStateOwnedEnterprises+=leaveUseVo.getStateOwnedEnterprises();
  88. }
  89. if(leaveUseVo.getGovernment()!=null){
  90. government+=leaveUseVo.getGovernment();
  91. allGovernment+=leaveUseVo.getGovernment();
  92. }
  93. allNum=person+personPrivate+stateOwnedEnterprises+government;
  94. allAllNum+=allNum;
  95. leaveUseVo.setAllNum(allNum);
  96. }
  97. cityList.add(list.get(0));
  98. }
  99. //对cityList 进行排序
  100. List<OtnAreaEntity> areaList=otnAreaService.getCityOption("018");
  101. List<WzHouseCustomerEntity> orderList=new ArrayList<>();
  102. for (OtnAreaEntity otnAreaEntity : areaList) {
  103. for (WzHouseCustomerEntity wzCity : cityList) {
  104. if(wzCity.getCity().contains(otnAreaEntity.getName())){
  105. orderList.add(wzCity);
  106. }
  107. }
  108. }
  109. province.setPerson(allPerson);
  110. province.setPersonPrivate(allPersonPrivate);
  111. province.setStateOwnedEnterprises(allStateOwnedEnterprises);
  112. province.setGovernment(allGovernment);
  113. province.setChildren(orderList);
  114. province.setAllNum(allAllNum);
  115. if(orderList.size()>0){
  116. resultList.add(province);
  117. }
  118. int total = wzHouseCustomerService.queryTotal(query);
  119. PageUtils pageUtil = new PageUtils(resultList, total, query.getLimit(), query.getPage());
  120. return R.ok().put("page", pageUtil);
  121. }
  122. }